No application encryption key has been specified

10.07.2019 - Записи в блоге

После клонирования проекта с gitlab приложение падает с симпатичной ошибкой 500. В журнале storage/logs/laravel-2019-07-10.log бэктрэйс ошибки
No application encryption key has been specified
Нужно сгенерить и прописать ключ приложения командой php artisan key:generate

При выполнении этой команды можно получить новый бэктрэйс:
ErrorException : file_get_contents(/var/www/dev1.project.ru/current/.env): failed to open stream: No such file or directory
at /var/www/dev1.project.ru/current/vendor/laravel/framework/src/Illuminate/Foundation/Console/KeyGenerateCommand.php:96
92| {
93| file_put_contents($this->laravel->environmentFilePath(), preg_replace(
94| $this->keyReplacementPattern(),
95| 'APP_KEY='.$key,
> 96| file_get_contents($this->laravel->environmentFilePath())
97| ));
98| }
99|
100| /**
Exception trace:
1 file_get_contents("/var/www/dev1.project.ru/current/.env")
/var/www/dev1.project.ru/current/vendor/laravel/framework/src/Illuminate/Foundation/Console/KeyGenerateCommand.php:96
2 Illuminate\Foundation\Console\KeyGenerateCommand::writeNewEnvironmentFileWith("base64:G8MYJj8Kyvmcb/d4juWvYC1gh26vk/fC13CfGSe/YxE=")
/var/www/dev1.project.ru/current/vendor/laravel/framework/src/Illuminate/Foundation/Console/KeyGenerateCommand.php:80
Please use the argument -v to see more details.

В таком случае, требуется выполнитьecho "APP_KEY=" >> .env и повторить команду php artisan key:generate

› tags: git / laravel / php artisan key:generate /