Thomas Venturini Thomas Venturini - 8 months ago 61
PHP Question

Lumen Micro Framework => php artisan key:generate

I'm trying out the PHP micro Framework Lumen (from laravel).

One of my first steps was to look into the

file and make a copy of it to have my
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

There are no commands defined in the "key" namespace.

Now after a bit of googeling which led me nowhere I am asking out for some help. So, does some one know how I can generate keys for Lumen?

Thanks in advance :)

Update with solution

So I found my favorite solution for this problem. On the commandline (linux) I run
php -r "echo md5(uniqid()).\"\n\";"
what gives me something like this

If you are going to use lumen more often, you may want to create an alias in your
, which is located in your home directory
. To do so, you can open the file with
nano ~/.bashrc
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
which will give you a 32 character long random string :)

Have fun with it! :)


The Laravel command is fairly simple. It just generates a random 32 character long string. You can do the same in Lumen. Just temporarily add a route like this:

$app->get('/key', function() {
    return str_random(32);

Then go to /key in your browser and copy paste the key into your .env file.
Afterwards remove the route.

Obviously you could also use some random string generator online. Like this one