Introduction to Lumen

Lumen is the new, official micro-framework by Laravel, built on top of Laravel's components.

Lumen vs Laravel

Lumen is not designed to replace Laravel, rather, it is a more specialized (and stripped-down) framework designed for micro-services and APIs.

Laravel is a full-stack web framework intended to be used to create full-featured websites. Some of the features in Laravel such as HTTP sessions, cookies, and templating are not needed if you want to write an API, which does not need a 'view' in the typical MVC model. So Lumen takes them away, keeping what's essential - routing, logging, caching, queues, validation, error handling, database abstraction, controllers, middleware, dependency injection, Blade templating, command scheduler, the service container and the Eloquent ORM.

Also, many of the configuration and customization settings you could alter in Laravel, are predetermined in Lumen.

Thus, Lumen is a smaller and more opinionated framework when compared to Laravel.

Benefits of Lumen

The benefit of Lumen when compared to Laravel is speed.

The framework also claims to be faster when compared to similar micro-frameworks such as Slim or Silex (which is based on Symfony 2 components). Slim has also commented on the release of Lumen, stating it has fewer dependencies than Lumen, amongst other things. Have a read and decide for yourself. There's definitely a lot of overlap.

Lumen use the same components as Laravel, and so the code you write in Lumen can be used directly in Laravel. If you are familiar with Laravel, you will find the syntax very similar. If you're new to both Laravel and Lumen, Lumen will be easier to learn (as there are less to learn).

You can also add Laravel components to Lumen to extend it, so it can be used for more than just micro-services and API. However, if your goal is to extend Lumen to become a website, you might as well use Laravel instead.

Summary

Lumen sacrified the flexibility of Laravel for speed.

Lumen and Laravel are meant to work together. For APIs and services are frequently get called, use Lumen. For user-facing applications, use Laravel.

Lumen distinguishes itself from other frameworks such as Slim and Silex because it allows you to use Laravel syntax and components, and 'upgrades' easily to Laravel. Lumen also claims to be faster than both Slim and Silex.

Further Reading

Adam Engebretson have written an excellent post on how to use Lumen to provide an API for your Laravel application, it's well worth a read!

comments powered by Disqus