Create REST API using lumen micro framework by laravel

We are going to implement REST API with newbie which is lumen micro framework and it made from Taylor Otwell use the same core of Laravel. But it’s designed to build service for small application with high speed performance(As per their benchmark 1900 Req/Sec). It doesn’t included all laravel components but laravel is a parent of lumen framework. Lumen uses the laravel features like routing, dependency injection, the Eloquent ORM, migrations, queued jobs, and even scheduled command.

In this tutorial, We are going to do install and implement simple restful API with lumen framework.


As per the documentation, We can install lumen via composer or the installer. With composer we can install composer create-project via terminal

If the packages are downloaded then we will start to modify app.php file which is located at bootstrap/app.php for enable or disable the features what we need. So we are going to enable Eloquent, Facade and Dotenv.


Lumen supports .env configuration, So we uncommenting the Dotenv line to activate the .env configuration or else you can directly use the configuration by coping the config folder from /vendor/laravel/lumen-framework/ to your project directory.

By using .env configuration, You should rename .env.example to .env and it set the config details like database details in this file


By using direct configuration, You can add database details to projectname/config/database.php and we should commenting the following line in bootstrap/app.php


Now the framework has been configured successfully. For more details about installation please refer documentation

Create Migration:

Migration is similar to laravel because it uses the laravel Eloquent ORM. Before we are going to create the migration table then we should install the migration by using the following command

Then We can create the migration table and the table name is articles

After run the above command it will generate migration file to database/migrations folder and we can edit schema details as per the documentation


We have added only two columns id, article_name and article_description. Then we need to run migration by using following command

Now all the migrations has been done and above command will create tables in database. Then we need to create model Article  to use Eloquent feature.

  • Agus Cahyono

    Thanks,,, this is great tutorial.

    • Azhagu Pandian

      Thank you @Agus Cahyono

  • Sunny Kinger

    Thanks. It is a great tutorial.
    Easy to understand.

    • Azhagu Pandian

      Thank you @Sunny Kinger

      • Sunny Kinger

        I need more help with the question I asked you on Google+.
        Do reply.

        • Azhagu Pandian

          I didn’t get any question on my google plus. Please send me the questions to my email

  • Grischa

    Somehow GET and DELTE works fine but PUT and others returns “405 Method Not Allowed”… Any ideas?