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.
source share