1
votes

After upgrading to Laravel from 5.5 to 5.6.12 I get following exception:

PHP Fatal error: Uncaught ReflectionException: Class env does not exist in /var/www/showroom-ng/vendor/laravel/framework/src/Illuminate/Container/Container.php:767 Stack trace: 0 /var/www/showroom-ng/vendor/laravel/framework/src/Illuminate/Container/Container.php(767): ReflectionClass->__construct('env') 1 /var/www/showroom-ng/vendor/laravel/framework/src/Illuminate/Container/Container.php(646): Illuminate\Container\Container->build('env') 2 /var/www/showroom-ng/vendor/laravel/framework/src/Illuminate/Container/Container.php(601): Illuminate\Container\Container->resolve('env', Array) 3 /var/www/showroom-ng/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(747): Illuminate\Container\Container->make('env', Array) 4 /var/www/showroom-ng/vendor/laravel/framework/src/Illuminate/Container/Container.php(1210): Illuminate\Foundation\Application->make('env') 5 /var/www/showroom-ng/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(492): Illuminate\Container\Container->offsetGet('env') 6 /var/www in /var/www/showroom-ng/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 767

I don't see anything related in the upgrade guide.

I tried to dig into Laravel internals, and for example removing code:

    if (! $app->environment('testing')) {
        ini_set('display_errors', 'Off');
    }

from vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php removes one occurrence of mentioned exception, but there is some other place which is causing the same one. I tried to use lower 5.6 versions of Laravel, but it doesn't change anything.

1
It would probably be relevant to tell us what you upgraded from, and the full stack trace of the problem. The most common problem is a bad config file. Other causes could be that you have overridden the $bootstrappers array in any of your kernels and forgot the LoadConfiguration bootstrapper.sisve
@sisve I updated from 5.5. I don't override any $bootstrappers, And I pasted the whole message which I get in the browser or in thePawel Ryznar
Had the same issue on Laravel 5.7. Please see answer here: stackoverflow.com/a/55768146/516352yunas

1 Answers

2
votes

So problem was with other exception which was occurring in Exception handler! when calling app()->environment() , which was hiding the real exception, which was related to trusted proxies https://stackoverflow.com/a/48595052/6852455