When do I need to create a new application key in Laravel?

Since it automatically installs it for me in my .env file when I create the application, I am not sure when I started it.

In addition to this, if a second developer and application clones come, does he / she need to run php artisan key:generate ?

How do we know exactly when to run php artisan key:generate ?

+6
source share
1 answer

php artisan key:generate is a command that sets the value of APP_KEY in your .env file. By default, this command is run after the composer create-project laravel/laravel . If you use a version control system such as git to manage your development project, calling git push ... will push a copy of your Laravel project where it is going, but will not include your .env file. Therefore, if someone clones your project using git clone ... , they will need to manually enter php artisan key:generate for their application to function correctly.

So TL: DR, the only time you need to call php artisan key:generate , follows the clone pre-created Laravel project.

Note: if you try to start a Laravel project with APP_KEY set to SomeRandomString (which is used by default in your .env.example file, you really get an error message:

No supported encrypter was found. Cipher and / or key length are not allowed.

+12
source

All Articles