bramcou
5 days ago

Uncaught ReflectionException: Class env does not exist in after upgrading laravel 5v5.8.33 > v6.18.15

Posted 5 days ago by bramcou

Hi all,

I'm having troubling upgrading my Laravel installation from 5.8 to the newest 6.15 (and intending on upgrading to 7.x hereafter).

After running composer update the composer dump autoload runs into trouble and I can't figure out what the problem is. Spent 2 hours on google. Apparently lots of peeps get the same problem only it's usually fixed by clearing cache files that are already cleared at my application, or they relate to telescope, which I don't use nor have installed.

  • I've cleared the bootstrap/cache/ folder. I don't cache the config nor route files.
  • I've followed the upgrade guide from 5.x to 6.0 and double checked but can't find anything I missed.
  • No spaces in my .env file (haven't touched the file in ages)

Running any artisan command just returns the same error:

λ php artisan -v

Fatal error: Uncaught ReflectionException: Class env does not exist in C:\Laragon\www\vezc\vendor\laravel\framework\src\Illuminate\Container\Container.php:803
Stack trace:
#0 C:\Laragon\www\vezc\vendor\laravel\framework\src\Illuminate\Container\Container.php(803): ReflectionClass->__construct('env')
#1 C:\Laragon\www\vezc\vendor\laravel\framework\src\Illuminate\Container\Container.php(681): Illuminate\Container\Container->build('env')
#2 C:\Laragon\www\vezc\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(785): Illuminate\Container\Container->resolve('env', Array, true)
#3 C:\Laragon\www\vezc\vendor\laravel\framework\src\Illuminate\Container\Container.php(629): Illuminate\Foundation\Application->resolve('env', Array)
#4 C:\Laragon\www\vezc\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(770): Illuminate\Container\Container->make('env', Array)
#5 C:\Laragon\www\vezc\vendor\laravel\framework\src\Illuminate\Container\Container.php(1245): Illuminate\Foundation\Application->make('env')
#6 C in C:\Laragon\www\vezc\vendor\laravel\framework\src\Illuminate\Container\Container.php on line 805

Below is the cli after all packages had been installed/updated/removed by composer when initially running composer update.

phpoffice/phpspreadsheet suggests installing mpdf/mpdf (Option for rendering PDF with PDF Writer)
phpoffice/phpspreadsheet suggests installing tecnickcom/tcpdf (Option for rendering PDF with PDF Writer)
phpoffice/phpspreadsheet suggests installing jpgraph/jpgraph (Option for rendering charts, or including charts with PDF or HTML Writers)
symfony/polyfill-uuid suggests installing ext-uuid (For best performance)
php-http/message suggests installing zendframework/zend-diactoros (Used with Diactoros Factories)
php-http/message suggests installing slim/slim (Used with Slim Framework PSR-7 implementation)
php-http/discovery suggests installing puli/composer-plugin (Sets up Puli which is recommended for Discovery to work. Check http://docs.php-http.org/en/latest/discovery.html for more details.)
php-http/client-common suggests installing php-http/logger-plugin (PSR-3 Logger plugin)
php-http/client-common suggests installing php-http/cache-plugin (PSR-6 Cache plugin)
php-http/client-common suggests installing php-http/stopwatch-plugin (Symfony Stopwatch plugin)
Package jakub-onderka/php-console-color is abandoned, you should avoid using it. Use php-parallel-lint/php-console-color instead.
Package jakub-onderka/php-console-highlighter is abandoned, you should avoid using it. Use php-parallel-lint/php-console-highlighter instead.
Package phpunit/phpunit-mock-objects is abandoned, you should avoid using it. No replacement was suggested.
Writing lock file
Generating autoload files
composer/package-versions-deprecated: Generating version class...
composer/package-versions-deprecated: ...done generating version class
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover

Fatal error: Uncaught ReflectionException: Class env does not exist in C:\Laragon\www\vezc\vendor\laravel\framework\src\Illuminate\Container\Container.php:803
Stack trace:
#0 C:\Laragon\www\vezc\vendor\laravel\framework\src\Illuminate\Container\Container.php(803): ReflectionClass->__construct('env')
#1 C:\Laragon\www\vezc\vendor\laravel\framework\src\Illuminate\Container\Container.php(681): Illuminate\Container\Container->build('env')
#2 C:\Laragon\www\vezc\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(785): Illuminate\Container\Container->resolve('env', Array, true)
#3 C:\Laragon\www\vezc\vendor\laravel\framework\src\Illuminate\Container\Container.php(629): Illuminate\Foundation\Application->resolve('env', Array)
#4 C:\Laragon\www\vezc\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(770): Illuminate\Container\Container->make('env', Array)
#5 C:\Laragon\www\vezc\vendor\laravel\framework\src\Illuminate\Container\Container.php(1245): Illuminate\Foundation\Application->make('env')
#6 C in C:\Laragon\www\vezc\vendor\laravel\framework\src\Illuminate\Container\Container.php on line 805
Script @php artisan package:discover handling the post-autoload-dump event returned with error code 255

Any help would be greatly appreciated!

Please sign in or create an account to participate in this conversation.