Framework: Uncaught ReflectionException: Class env does not exist

Created on 26 Nov 2018  路  9Comments  路  Source: laravel/framework

  • Laravel Version: 5.7.15
  • PHP Version: 7.2.12
  • Database Driver & Version: Mariadb 10.2

Description:

`PHP Fatal error: Uncaught ReflectionException: Class env does not exist in /var/www/project/vendor/laravel/framework/src/Illuminate/Container/Container.php:779
Stack trace:

0 /var/www/project/vendor/laravel/framework/src/Illuminate/Container/Container.php(779): ReflectionClass->__construct('env')

1 /var/www/project/vendor/laravel/framework/src/Illuminate/Container/Container.php(658): Illuminate\Container\Container->build('env')

2 /var/www/project/vendor/laravel/framework/src/Illuminate/Container/Container.php(609): Illuminate\Container\Container->resolve('env', Array)

3 /var/www/project/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(735): Illuminate\Container\Container->make('env', Array)

4 /var/www/project/vendor/laravel/framework/src/Illuminate/Container/Container.php(1222): Illuminate\Foundation\Application->make('env')

5 /var/www/project/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(485): Illuminate\Container\Container-> in /var/www/project/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 779

`

Steps To Reproduce:

php artisan

I followed the upgrade guide, maybe i missed something, i think not.

Most helpful comment

For someone still having the issue, it can be solved adding

<server name="TELESCOPE_ENABLED" value="false"/> in phpunit.xml.

All 9 comments

Can you first please try one of the following support channels? If you can actually identify this as a bug, feel free to report back.

Also check the issue tracker if your issue can be found somewhere here: https://github.com/laravel/framework/issues?q=is%3Aissue+Class+env+does+not+exist+is%3Aclosed

Are you using Telescope? Is this the problem you're experiencing? https://github.com/laravel/telescope/issues/347

yes, im using Telescope. Tx!

I've runned

php artisan clear
php artisan config:clear

Solved for me

For someone still having the issue, it can be solved adding

<server name="TELESCOPE_ENABLED" value="false"/> in phpunit.xml.

Put it together:

<server name="TELESCOPE_ENABLED" value="false"/>
php artisan optimize

I'm not using telescope package, but i've received the same exception on every php artisan call.
I didn't understand what code block crashes.
Over internet there are many resolutions with cache cleaning. Those users received the same message while running phpunit command.
I've tried to run phpunit and received an error related to configuration of one of packages that i've used. So I fixed package config problem and phpunit command runs well. Also, php artisan runs OK for now.
Hope my solution will be useful to someone.

I had the same problem after upgrading with composer update. I had to downgrade. Nothing above worked for me.

Some problem after upgrading from 6 to 7 version

Lumen, upgrading from

  • Updating laravel/framework (v8.14.0 => v8.18.1): Downloading (100%)
  • Updating laravel/lumen-framework (v8.2.0 => v8.2.1): Downloading (100%)

Happened during seeding
User::factory()->count(200)->create();

Actually a simple
$factory = User::factory();
was enough to make that error

Workaround:

$factory = \Database\Factories\UserFactory::new();
$factory->count(200)->create();
Was this page helpful?
0 / 5 - 0 ratings

Related issues

jackmu95 picture jackmu95  路  3Comments

SachinAgarwal1337 picture SachinAgarwal1337  路  3Comments

RomainSauvaire picture RomainSauvaire  路  3Comments

fideloper picture fideloper  路  3Comments

JamborJan picture JamborJan  路  3Comments