Developing a Micro-Service with Lumen

I introduced Lumen to you all in my previous post. Today we’ll be creating a simple microservice with Lumen.

Let’s give the name of the service we’ll be building “Developer Status“. .

So, the idea is to build a microservice that showcases your Developer Evangelist status based on the number of public repos you have on Github. The assumption here is that the more publicly available repos you have on github, the more you support the idea of Open back to the community.

Create a new Lumen Project

From your terminal, run the following command:

DevStatus is the name of our new app. The command creates a new folder for it and downloads all the dependencies.

To see our application live we need to cd into our DevStatus folder and run:

Our project will be up and running on

Now, there are a number of configurations we’re required to make if we are going to use a database.

1. Enable Eloquent

Edit the app.php file in the bootstrap folder and uncomment the following lines:

The first line enables the support for Facades (a very common feature used in Laravel and inherited by Lumen) that simplifies the usage of some of the core classes of the framework while the second enables us to work with Laravel’s ORM.

2. Enable .env

Edit the app.php file in the bootstrap folder and uncomment this line:

This allows you to use the .env file to store your Database credentials and other important secret values.

Presently, for the microservice we are building, we don’t really need any of that so we’re at liberty not to configure any of that.


We need to configure our routes. Navigate to app/Http/routes.php.

Let’s edit routes.php to set up our routes.

Reload your browser, you’ll see a JSON response like this:

Let’s set up our second route to take in a github user’s username

This is the how the result would look in our browser:

Screen Shot 2015-04-26 at 1.32.26 PM

Note: i use a JSONVIEW chrome plugin to format json output nicely in my browser.

Now, we need only the “public_repos” and “name” data. Let’s tweak our code to involve the logic for determining a Developer status.

The $options variable contain header information sent to github Api as part of our request. If the HTTP_USER_AGENT is not sent, then github would decline our request.

Then our result should look like this now:

Screen Shot 2015-04-26 at 1.50.19 PM

Check Out The Code here:

Feel free to ask your questions in the comment section.

Finally: pls don’t put your logic in your routes when building apps/microservices..Let them be inside your controllers to ensure modularity, separation of concerns and overall clean code!.



Food Ninja, Code Slinger, Technical Trainer, Accidental Writer, Open Source Advocate and Developer Evangelist.