问题
For some reason one of our applications isn't booting anymore. The stack trace looks like this:
PHP Fatal error: Uncaught RuntimeException: A facade root has not been set. in /app/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:218
Stack trace:
#0 /app/app/Exceptions/Handler.php(43): Illuminate\Support\Facades\Facade::__callStatic('get', Array)
#1 /app/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(352): App\Exceptions\Handler->report(Object(Dotenv\Exception\InvalidFileException))
#2 /app/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(123): Illuminate\Foundation\Console\Kernel->reportException(Object(Dotenv\Exception\InvalidFileException))
#3 /app/artisan(37): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#4 {main}
thrown in /app/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php on line 218
I'm sure there's something that changed and stopped the application from booting. But I have no clue what exactly happened. Any help is greatly appreciated.
回答1:
The solution was quiet simple but difficult to find.
.env variables should not be assigned as KEY="VALUE" and also too many spaces can crash the initialisation of the .env
i.e: DB_HOST= mysql
Just correct the .env and it should work like a charme
回答2:
As a sanity check, completely delete your vendor
directory and then re-install (or update) your dependencies. It is possible a file in there was mistakenly changed and is now causing problems.
rm -rf vendor
composer update
来源:https://stackoverflow.com/questions/54659453/laravel-5-5-application-not-booting-anymore-with-a-facade-root-has-not-been-set