Request a Proposal



Using Lumen for lightweight micro services and APIs

NetFillip Jan 10, 2019 PHP, Web Development

Whenever a light weight application is required, using of full framework with lots of features is not a good idea. There might be many functions that is not required to your application which increase application size and execution speed. To overcome this we are here with Lumen, A PHP based micro-framework which is smaller,faster and ideal for building lightning fast micro-services and APIs which are optimized for speed.


lumen uses the Illuminate components that power the Laravel framework. It can handle more requests per second than Laravel. In fact, it’s one of the fastest micro-frameworks available. Some features are mentioned below,


Lumen provides routing out of the box via Fast Route. Fast Route is a library that provides a fast implementation of a regular expression based router. It uses nikic/FastRoute instead of Symfony, thereby increasing performance.


HTTP middleware provide a convenient mechanism for filtering HTTP requests entering your application.


Uses same library as laravel but configured quite differently. Lumen does not support session state, incoming requests that you wish to authenticate must be authenticated via a stateless mechanism such as API tokens.


Lumen supports caching just like Laravel. Need to install the illuminate/redis package via Composer before using a Redis cache with Lumen.

Errors & Logging

Lumen ships with the Monolog library, which provides support for various log handlers.


Lumen provides a queuing service that is similar to Laravel’s. It  provides a unified API across a variety of different queue back-ends.


Lumen’s events provide a simple observer implementation, allowing you to subscribe and listen for events in your application.

Lumen API development and consuming it for An e-commerce Application built in OpenCart

E-commerce application  manage products, customers, orders, taxes rules, coupon codes and more.


We need to implement a module where thousands of unique product records are being inserted, updated and deleted through excel sheet on specific time interval twice in 24 hours. Application features like vendors creation and deletion, activation and suspension of specific vendor due to non-compliance, fetching records based on markups were the basic components of module. After rigorous data and load testing, we evaluated the server key performance metrics and the results were not satisfactory. The reports revealed over-utilization of server resources, the web server was crashing, memory limit was over exhausted every time the database operations were performed, & at the same time, end users complained for slow accessing of the web-app or sometimes complete shut-down.


To overcome above problems, we decided to build bunch of APIs as per our module that had been staged on different web-server or we can call it as API-gateway. Lumen as API development platform was chose (Laravel based micro-services and blazing fast APIs). Below are the APIs we have created,

  • Vendor Registration : New Supplier can be can be easily created.
  • Vendor Activation/Deactivation : Suppliers can be activated for upload data sheet and display it in fetch API, if deactivated then supplier cant’t upload data through excel sheet.
  • Vendor Deletion : Suppliers can be deleted using this API.
  • Fetch Data for dashboard : API to fetch data which can be easily mapped with graph representational.
  • Apply Markup : Markup can be easily applied based on different parameters like price, size.
  • Authentication : To fetch data authentication of user is required once authenticated it will return data.
  • Fetch data for End users : Fetch data based on different filters which can be display in front user.
  • Excel Sheet Upload : API to upload file based on time interval applied in cron job automatically or can be upload manually by selecting a excel sheet.


By using all the above APIs we were able to upload excel sheet, supplier create/delete, apply markups and fetch data with different filters from eCommerce application. The results were awesome. Server performance was very good on all the metrics. The slow speed of the app, high download time and data rendering issues were resolved. The users had a very good comments on the new adoption.

Add your comment