key:generate
command is used to generate a random key. This command will update the key stored in the application's environment file. The command also supports an optional --show
flag. Specifying this flag will simply show the generated key instead of updating any configuration or environment files..env
using PHP. .env.example
file and make a copy of it to have my .env
file. There is a variable APP_KEY just like there is in Laravel. Now I tried out the simple command php artisan key:generate
to get my new key But I ran into the following error message: php -r 'echo md5(uniqid()).'n';'
what gives me something like this 7142720170cef01171fd4af26ef17c93
. .bashrc
, which is located in your home directory /home/USERNAME
. To do so, you can open the file with nano ~/.bashrc
or vi ~/.bashrc
and copy the following alias at the end of the file, alias phpkey='php -r 'echo md5(uniqid()).'n';'
. Now you can use the command phpkey
which will give you a 32 character long random string :) .env
file.