.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 ?/key
in your browser and copy paste the key into your .env
file.app/Console/Commands/KeyGenerateCommand.php
. To make this command available in artisan
, change appConsoleKernel.php
:IlluminateConfigRepository
instance has app.key
value. To do this, change bootstrap/app.php
:.env.example
file to .env
:.env
file.key:generate
command via:tinker
, because that is not available with Lumen):Str::random()
function that makes use of the secure random_bytes()
function.openssl rand -base64 24
date | md5
on macstr_random
can help us, but this function is part of Laravel/Lunmen framework.php artisan tinker
>>> str_random(32)
=> 'y3DLxnEczGWGN4CKUdk1S5GbMumU2dfH'
composer require flipbox/lumen-generator
$app->register(FlipboxLumenGeneratorLumenGeneratorServiceProvider::class);
into bootstrap/app.php
file..env
file.php -a
to start up interactive php playground.echo substr(md5(rand()), 0, 32);
to generate a 32 character string. .env
file..env
and updating it with an APP_KEY
using the aforementioned PHP command and the UNIX sed
command:.env
using PHP..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.