Getting Started with Lumen

Lumen is a micro Framework version of Laravel. Basically its a stripped down version of Laravel that has been optimised for speed. It is appropriate for use in a range of situations where the full version of laravel is not required or where resources are at a minimum. One area where Lumen has become popular is in the development of REST Apis.

In this section we are going to use Lumen to develop a REST Api version of our tennis club application. The purpose here is merely to introduce REST Apis as an alternative approach to developing a system.

To create a lumen application in your laravel folder type

php composer.phar create-project --prefer-dist laravel/lumen lumenTennis

In order to get your application working you will need to generate a unique application key. In the later versions of the full version of laravel this is done for you but as the lumen framework is completely stripped down we will have to do it manually.

To generate the key type the following into the CLI

php -r "echo md5(uniqid()).\"\n\";"

This will generate a random 32 character long string as follows

Copy and paste this String from the CLI into the .env file as follows

While your editing the .env file take the opportunity to update your database credentials as above.

To start your application server type the following in your application root folder

php -S localhost:8000 -t public

This will start your application server listening on port 8000 and will set the folder \lumenTennis\public as your application root folder. Now if you visit localhost:8000 you will see a very brief response in line with Lumens stripped down nature.

Leave a Reply