So, I have been building a laravel 5.1 API and after months of work on it it dawned on me that I should have been using Lumen all along.
Is there a way to convert a laravel app to a lumen app?
Laravel is better for building RESTful APIs. Lumen is better for building high performing micro framework API. Laravel can handle event queuing and has a powerful template. Lumen can't handle the event queuing and don't have any powerful template either.
Key Differences between Laravel vs Lumen Laravel is a full-stack web application framework that packages or supports a lot of third-party tools and frameworks, whereas Lumen is a micro-framework that is used to develop microservices and API development with the intent of providing speed and high response time.
The number of requests handled by Laravel is higher than that of Lumen. This is the reason why Lumen is the fastest Micro Framework whereas Laravel is much slower. To be precise, Lumen handles 100 requests per second. So, if speed is your requirement, then you know which framework to choose.
Lumen is essentially a stripped down version of Laravel. The application structure is the same, so as far as that goes it should be safe to create a new Lumen app and copy the app
directory from your Laravel app.
However, for performance reasons, Lumen does not have all the Laravel goodies working out of the box, and some are not there at all. So depending on how you've implemented you're Laravel app, here's a few things that you might need to change in order to migrate your app:
.env
file by default, so you need to uncomment the line Dotenv::load()
in bootstrap/app.php
if you want it to workDB
, Mail
, Queue
are also not enabled by default. You can enable them by uncommenting $app->withFacades()
in bootstrap/app.php
. However, even if you do enable them you only get a portion of the facades that you get in Laravel$app->withEloquent()
in bootstrap/app.php
I've probably not covered everything, but this is to offer an idea on what you should be looking out for. All those things can be enabled, but the performance benefits Lumen brings are mostly because those things are disabled to get rid of that overhead, so try to modify your application wherever possible to make use of what Lumen offers by default.
Assuming everything you are using is in the Lumen documentation and actually available to Lumen, you should be able to create a new Lumen project and drop your app folder from Laravel into the new Lumen project.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With