Converting a laravel application to lumen
Asked Answered
I

2

12

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?

Inadequate answered 19/11, 2015 at 18:19 Comment(1)
You would never want to go this direction anymore. Modern Laravel is just as fast as, if not faster, than Lumen. Especially with recent offerings like Octane and Vapor. Furthermore, Lumen is effectively "dead" as it rarely has new features or community support.Fibrillation
B
23

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:

  • Route definitions will have to be migrated because Lumen uses a different router
  • Lumen does not use the .env file by default, so you need to uncomment the line Dotenv::load() in bootstrap/app.php if you want it to work
  • Facades such as DB, 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
  • Eloquent needs to be enabled by uncommenting $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.

Belen answered 19/11, 2015 at 18:48 Comment(2)
chosen as answer because stackoverflow says you posted a minute before the other and its well thought out with caveats and such. Thanks!Inadequate
I'm definitely using Eloquent so that will probably be my biggest hurdle. The cors and larasponse packages i am using both seem to have lumen install instructions so this should work pretty well. Thanks again!!Inadequate
D
1

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.

Dilantin answered 19/11, 2015 at 18:47 Comment(1)
ill try that ASAP. Thanks for the heads up!!Inadequate

© 2022 - 2024 — McMap. All rights reserved.