On my production server I set the env var APP_ENV=production
. With this config laravel will not use .env file but it will use env var declared on the server.
But I have a problem when I run this command php artisan key:generate
because I'll get this error:
In KeyGenerateCommand.php line 96:
file_get_contents(/app/.env): failed to open stream: No such file or directory
Just for this command laravel need the .env file. So actually I create an empty .env file to make it works but it's ugly...
Do you have any solution ? or maybe this command is useless in production env ?
CodePudding user response:
When you push a Laravel project to production, you need to generate a .env
file, since that file is not committed. You should have a .env.example
, which you can copy and modify as required:
cp .env.example .env
Then you can run php artisan key:generate
to set the App Key.