Lumen — A Magnificently Fast Micro-service PHP Framework — Part I

9series Solutions
4 min readSep 19, 2018

Lumen was created by Taylor Otwell in 2015 who was also the founder of Laravel framework. It is a PHP based micro-service framework. It is an open-source php framework. Lumen is designed for building very fast micro-services and APIs.

Lumen is a “micro-framework”, meaning it’s a minor, speedy, leaner version of a full web application framework. It is basically built for more speed, it is faster than similar PHP micro-service frameworks such as Slim & Silex.

Based on the benchmark tests by Taylor Otwell — the creator of Laravel framework, Lumen is the fastest micro framework followed by Slim then Silex.
Lumen — 1,700 requests per second
Slim — 1,250 requests per second
Silex — 950 requests per second

Please Note: The results mentioned above are of slim version 3. The Slim micro framework version 3 has not been released officially. But the results of the slim framework version 2 are quite close to the results of Lumen.

Some Important Features of Lumen Laravel
~
Lumen Laravel is blazing speedy.

~ Lumen has simple syntax.

~ It can be easily upgraded to the full Laravel project.

~ It can handle more requests per second than Laravel framework.

~ Routing: Lumen gives fastest routing feature by Fast Route. Fast Route is a library which provides fastest implementation of a regular expression based router.

~ Events: Lumen event provides a simple observer implementation which allows us to subscribe and listen to events in our application.

~ Authentication: A session state is not supported by Lumen. Stateless mechanism such as tokens are used for authentication process.

~ Caching: Same as Laravel, Lumen supports caching feature. No more difference in caching feature of Laravel and Lumen. In Lumen, Cache drivers such as Database, Memcached, and Redis are supported.

~ Errors and Logging: Lumen gives a Monolog library, which provides support for various log handlers.

~ Queuing: Lumen provides a queuing service which is same as Laravel’s queuing service.

Difference between Laravel & Lumen
1. Laravel is a web based framework with significant, classic syntax. And Lumen is a stunningly fast micro-service framework based on PHP for building web applications with classic and significant syntax.

2. Lumen is a more specialized and stripped-down framework developed for Micro-services development and API development. So, many of the features in Laravel such as HTTP sessions, cookies, and templating are not required and Lumen takes them away, keep only which is essential — routing, logging, caching, queues, validation, error handling and a some of others.

Lumen Key Requirements
For Lumen, you will need to make sure your server matches with the following necessary requirements.

~ Make sure PHP is installed on your machine. Some of the PHP extensions such as OpenSSL, PDO and Mbstring are required for installing Lumen.

~ Composer: Go to the composer website and install it on your machine. Composer is required to install dependencies of Lumen framework.

~ Database concepts and working knowledge of PHP is also required.

Installation
There are two ways to create Lumen project:
1. Via Lumen installer
2. Via Composer Create-Project

Via Lumen Installer
First, download the Lumen installer using Composer:
~ Composer global require “Laravel/Lumen-installer”
Once installed, the Lumen new command will create a fresh Lumen installation in the directory you specify.

~ This method is more faster than installing via Composer: Lumen new blog

Via Composer Create-Project
~ Now one can even install Lumen by issuing the Composer create-project command in your terminal:
composer create-project –prefer-dist Laravel/Lumen blog

Serving Your Application
~ php -S localhost:8000 -t public

Why not choose Lumen
~
Unlike the Laravel framework, Lumen is not as configurable. The full-stack Laravel framework has multiple configuration files while in Lumen, each configuration option for Lumen framework is saved in a single .env configuration file.

~ Lumen does not use Symfony’s Routing component. Instead, Fast Route is used for better performance. If you require Symfony Routing features like sub-domain routing or optional parameters, you should use the full Laravel framework.

~ Syntax — If you don’t like Laravel coding then you’re not going to adopt Lumen.

~ Limited adoption — The ratio of Laravel to Lumen Shifts is pretty staggering — about 500 to 1. The Laravel Framework currently has around 20M downloads, while the Lumen Framework has around 125k. So that ratio is 160 to 1.

~ Less focus — Lumen laravel has a very lesser feature set. Lumen caters strictly to API development. So sometimes developer finds it restricted.

~ If a project is already implemented with another framework other than Laravel, it would be better to use another micro-framework for micro-services instead of Lumen.

Conclusion
So, Lumen PHP micro framework is a new PHP micro framework from Laravel that you can use to create powerful APIs and API based web applications. As described you can easily install Lumen laravel. Projects created using Lumen can be easily converted into Laravel projects without changing a thing. This is the 1st Blog in the Series.

Stay Tuned to read Part II!

Source : https://www.9spl.com/blog/lumen-magnificently-fast-micro-service-php-framework-part-1/

--

--

9series Solutions

9series is an eminent enterprise mobility & website development organisation with niche in delivering quality services & solutions to customers across the world