Creating a key for a new Lumen Micro Framework install
Lumen is the smaller but faster brother of the popular Laravel Framework. And faster means less features out of the box.
Starting a new Lumen framework is quite easy, once you have the Lumne installer globally installed. I can recommend that.
Install Lumen installer globally
composer global require "laravel/lumen-installer=~1.0"
Once you have installed a new Lumen framework, you actually have to do a few things extra:
- copy the example.env to .env
- generate an app key
With Laravel you can issue the command php artisan key:generate to generate the key, but Lumen doesn’t have that feature. Remember it’s smaller to be faster.
Of course you can do it manually, but let’s create a small shell script to do a few things manually.
A helper-script for a new Lumen install
#!/bin/bash if [ "$1" != "" ]; then #setup default directory cd /home/user/web lumen new $1 cd $1 cp .env.example .env key=`php -r "echo md5(uniqid()).\"\n\";"`; sed -i "s/APP_KEY=SomeRandomKey!!!/APP_KEY=$key/" .env fi
Save the script as newlumen.sh in ~/bin, set the appropriate execute permission and you can install a new Lumen framework, by running:
It will run all the mentioned steps above automatically:
- create a new Lumen install
- copy the .env file
- generate an application key in the .env file