What is Lumen – The Micro Laravel framework?
Heard of Lumen, the micro larval framework that’s becoming trendy these days? It is the thing that is getting the developers excited these days because it’s made application development easier for them.
Lumen is a micro framework created by the creator of Laravel. Yes, that’s right! Taylor Otwell who created Laravel, the popular open source PHP framework has created Lumen too. Lumen makes things smaller, simpler, faster and leaner. And it is used to build high performing micro services with loosely coupled components, making it easier for developers to make improvements and updates, with minimal complexity.
Lumen is much faster than other similar frameworks of its kind, for example, Slim and Silex. The main purpose behind the framework is speed, and that’s what it is striving to achieve. Being a micro-framework, Lumen is not likely to replace Laravel any time soon. However, it does have a foundation level that looks almost like the Laravel, and its components. But it has fewer configuration parameters for configuring web applications.
Noted features of Lumen
- Lumen is super-fast
- It is open source
- Has a simple syntax
- Has the capability of several requests in one second
- Fast route feature
- Eloquent ORM
- Blade Templating
- Database Abstraction
- Error Handling
- Queued Jobs
- Dependency Injection
Lumen is known for its Fast Route package for the router, a library that provides quick implementation, instead of the router that comes with Laravel.
Lumen has the Events feature with its simple observer implementation to subscribe and listen to the events in the application.
For the authentication process, Lumen uses Stateless mechanism like tokens, instead of session state.
Support for caching is an interesting feature for Lumen, the same as Laravel. Cache drivers like Memcached, Redis and Database are all supported here.
The micro-service has almost the same Queueing service as Laravel.
Comparison between Laravel and Lumen
Even though the creator of both frameworks is one, there are plenty of differences between the two. Licensed under MIT, Laravel is a robust MVC framework for developing web applications in PHP. Lumen has the same foundation level as Laravel, and taps into the full power of the framework, mainly Eloquent ORM, queued jobs, dependency injection, routing, some scheduled commands and so on. With Lumen, there is less flexibility in extending and changing the bootstrap files.
As Lumen is a micro-service, so it is much more specialised in API development and development and being a stripped down framework, many of the features in Laravel need not be in this one too.
While Laravel can be used for all sorts of application development, Lumen is suitable for certain specified services like templates, caching, cookie development, APIs, templates etc. Laravl just needs the required extended components and tools for building the concerned application. Lumen is lighter, and driven by micro services.
Laravel is a full-stack framework, and this opens up integration of an array of tools to extend its features. Lumen does not extend so much, and there are restrictions on the tools and third-party components that you can integrate. Also, it is not possible to integrate Laravel based projects within Lumen, but you can use the Lumen APIs while developing applications.
Laravel aligns perfectly well with the database functionality, and it can easily handle SQL queries and adopt the changes. This is an advantage with Laravel, and Lumen doesn’t have that benefit, and with the micro-framework, you need to juggle SQL queries.
Lumen has absolutely no learning curve, so it is a pretty easy framework to learn. Laravel is much bigger, and hence there is a learning curve to master the art.
Lumen has limitations too
Though a stunningly fast framework, Lumen does have its set of limitations. It is not as configurable as the Laravel framework, nor as flexible. The performance aspect of the micro-framework is achieved by removing the flexibility feature of the framework, especially in areas of configuration and amending the default boot process.
Lumen doesn’t let you use Symfony’s Routing component, so you have no access to features like subdomain routing, optional parameters etc. You have to use /- for increased performance. If you need Symfony Routing features, switch to Laravel.
And, Lumen cannot be configurable as the Laravel framework. You cannot override framework boots trappers to change how the framework is constructed. You cannot use Lumen with debug bars, CMS systems and additional Laravel packages.
When to choose Lumen
Lumen is built for speed, and it is significantly faster than all other micro-frameworks in its league. Laravel is also fast, but you don’t have to go through the configuration and customisation options, thereby saving loads of your service’s load time. The speed of Lumen, and the ease of Laravel’s features, makes it an obvious choice among developers.
Lumen is also a good choice when your priority is to cut server costs, especially when one aspect of the application (made with Laravel) receives more traffic than the rest. You can just build that aspect of the application as a separate Lumen application and make it work.
Lumen is perfect as PHO micro services because it has a unique bootstrapping process that allows developers to create high performing applications.
The author: Sascha Thattil works at Software-Developer-India.com which is a part of the YUHIRO Group. YUHIRO is a German-Indian enterprise which provides programmers to IT companies, agencies and IT departments.