top | item 9374691

Lumen – A micro-framework by Laravel

226 points| ericbarnes | 11 years ago |laravel-news.com

110 comments

order
[+] j42|11 years ago|reply
As someone who develops/maintains many high-IO requirement PHP microservices (as part of a service-oriented architecture, or, SOA), I'm torn on this one.

Laravel is one of my favorite frameworks, especially since 5.0 given its noble attempt to adhere to contract-first/interfaced development and many best practices that in some ways prevent the "worst" kinds of code from being written. It's not static typing, but it's a step in the right direction.

This seems like it's heavily optimized over the Laravel base, and if high speed and concurrency is important enough that you'd choose Lumen, then it seems like you'd still be stopping halfway in a bit of a "if you have a hammer everything seems like a nail" situation. Unless I'm missing something Lumen still requires resources to be bootstrapped on request, and ultimately that (in the context of a framework) will lead to memory leaks in a loosely-typed language; no way around that.

Also because disk writes will quickly become the bottleneck before your network capacity does, the two most relevant performance enhancements are to use a non-blocking event-loop (with expensive writes deferred to a tick cycle) and to completely avoid any unnecessary per-request bootstrapping--best done with raw PHP and ideally kept simple. This, combined with an optimized TCP configuration and split-per-process nginx LB at the head will give me r/s 10-50x the purported benchmarks. As much as 1000x when introducing intelligent edge-caching rules.

Is there a situation where this would be the right tool for the job/more ideal than the base framework but not worthy of a "roll-your-own" solution?

Either way +1 for Taylor Otwell as a developer and the general quality of his code/releases--Laravel is an ambitious project, and as a developer quite enjoyable to work with!

[+] monk_e_boy|11 years ago|reply
I guess if the micro service is using a bunch of shared code from a Laravel project (maybe just interfacing with the database) or if your team is large and already using Laravel, then the first step of optimizing a service into a 'micro service' is to use Lumen. Then step two (if Lumen isn't going fast enough) is to go raw PHP as you described.

But if your service is getting that popular, memory leaks are going to be a problem, maybe moving to HipHop (or whatever it's called now) or Node or something is a better idea.

Sounds like you're having fun!

[+] noir_lord|11 years ago|reply
I'm a php dev (amongst others) and I use it everyday at work but if I'm getting to the point where lumen or something like it is the bottleneck I'd just dump PHP altogether and go to a compiled language.

There is a niche I think for faster than laravel but not incredibly optimised, its another tool not the tool.

[+] driverdan|11 years ago|reply
> Lumen still requires resources to be bootstrapped on request, and ultimately that (in the context of a framework) will lead to memory leaks in a loosely-typed language; no way around that.

Can you expand upon that or provide a link with more info? Why would it lead to memory leaks?

[+] dustinlakin|11 years ago|reply
PHP frameworks have come a long way, and so has the language. The big thing that stands out, is that three of the best frameworks in the space (Laravel, Symfony and Slim) work together and feel a friendly/healthy sense of competition. They are reusing each others components and building a much more promising future for PHP.
[+] monk_e_boy|11 years ago|reply
Drupal 8 is based on Symfony -- things are really moving in the right direction.

Personally, I was a huge fan of Zend Framework + Doctrine, but these frameworks are all mature and great to use.... almost as good as Rails (lol, OK, OK, don't mention Ruby within earshot of PHP fans ;)

[edit] down voted for my opinion! Argh my tiny karma is depleted -- damn you ruby, damn you to hell!

[+] jcroll|11 years ago|reply
Which project reuses laravel components?
[+] hising|11 years ago|reply
Looks nice, I really like Slim Framework, this looks a lot like Slim from what I could tell. Gonna be interesting to see how (if at all) this will effect some performance focus from the Slim developers.
[+] jonkiddy|11 years ago|reply
I completely agree. I've used Slim in lieu of Laravel for a number of small API projects. I'm excited about porting them over to Lumen.
[+] bhauer|11 years ago|reply
I've just created an issue [1] in our FrameworkBenchmarks project to solicit an implementation of our tests on Lumen. If anyone here is willing to contribute such an implementation, it would be greatly appreciated. The promise of performance caught my eye!

Incidentally, Round 10 is arriving soon.

[1] https://github.com/TechEmpower/FrameworkBenchmarks/issues/15...

[+] seandavidfisher|11 years ago|reply
Looks really interesting. PHP may not be the "hip" language to use (although it's getting better), but it's so popular and accessible that disregarding it as a legitimate option for new projects is myopic.
[+] pyre|11 years ago|reply
I've talked to people doing large-scale deployments in PHP that complain about things like memory-leaks, etc in the language, so I'm not entirely convinced that PHP is really an excellent language (and runtime) that just happens to get a bad rap.
[+] wesray|11 years ago|reply
The drop in functionality right into the full framework is fantastic. Really like the ability to write API's with much less overhead, which was a factor that came into play for me recently. Nicely done Mr. Otwell.
[+] xrstf|11 years ago|reply
The same holds true for Silex[1], the Symfony Components-based micro framework. Silex and Lumen look very similar (not only because Laraval/Lumen use Sf Components as well), not only because both use (just as Laravel) Sf Components. Slim 3 seems to move in the same direction of modern PHP frameworks, where you return a response from your controller, instead of setting up some global state (the main thing I don't like about Slim 1 & 2).

For now, Silex is still my favorite, as it has the temporary bonus of having more providers available to integrate 3rd party libraries. Sure, I can drop-in whatever library I like, but having someone do the setup (configuring Twig alone can be a burden if you want to get it right) just makes it easier for me ;)

[1] http://silex.sensiolabs.org/

[+] debaserab2|11 years ago|reply
This is definitely a very cool feature and makes this a very good candidate for MVP's or prototypes. I'm not a huge Laravel fan, but this feature alone might sway my decision.
[+] cdnsteve|11 years ago|reply
This is a serious advantage to other frameworks if this principal holds true. I think anyone working in PHP has had their tails burnt a little too often with all the framework churn.
[+] fideloper|11 years ago|reply
Also interested to see what projects use this as a core "micro framework" service or with an SOA architecture. Seems like good flexibility between framework power and lightweight.
[+] Beatus|11 years ago|reply
I've just created a project with lumen to have a look at it and lumen and all its vendor packages (with --no-dev and without tests) contain 1522 files and 102449 lines of code – according to cloc.

Am I doing something wrong or why does it call itself a "micro-framework". A newly created Slim project contains 7417 lines of code.

[+] pan69|11 years ago|reply
How many lines of code should a micro framework have?
[+] debaserab2|11 years ago|reply
Where's the source for the benchmarks that are displayed as the first item on the project page for this?
[+] sergiotapia|11 years ago|reply
How painless is deploying a Lumen/Laravel application? I used to use PHP back in 2006 and I remember deploying was as easy as pushing a .php file via FTP.

Has the experience remained the same? PHP was incredibly simple to deploy.

[+] alanstorm|11 years ago|reply
> Has the experience remained the same?

Yes and no. The PHP language and run-time continue to value backwards compatibility and, ultimately, a PHP application is still just a collection of PHP files sitting on a web server somewhere. If you want to work like it's 2006 you can.

However -- Modern PHP (Laravel included) bring a few winkles to the table and most deployments will have extra complications for folks expecting to just "FTP a file" (also, I hope you meant SFTP a file (-:)

For example, Laravel (similar to rails) has migrations for creating and updating your database schema. You don't need to use migrations, but if you do your deployment becomes a bit more complicated.

Also -- although PHP namespaces have come a long way, they're still not up-to-par with (or, in PHP group-speak "have different goals than") ruby or python's module system. The Composer packaging system has stepped in to fill this gap, but this means a modern PHP deployment needs to

1. Generate composer autoload cache files 2. Fetch, download and install any updated composer packages (i.e. third party libraries)

Again, there's nothing stopping you from working locally and SFTPing or rsyncing all your local files (composer packages/autoload files included) to the server, but most teams develop a more formal deployment process than that.

How you host your PHP application is going to effect how you deploy. There's still many, many PHP hosting companies offering `mod_php` based hosting, but there's also a large number of projects who use a Fast-CGI/FPM approach (either with Apache or nginx). The difference in process models brings a different in the unix permissions model, and that often means there's extra steps needed to ensure file based cache system can write to their storage engines.

And speaking of caching, 20% of any "serious" PHP developer's time is spent sorting out the various framework level caching systems, as well as PHP based opt-code caching. I mention this here mainly to point out that some sort of cache refresh and/or warming is common in signifigant/long-standing PHP systems.

Deployment's still easier in PHP than in other frameworks, but if you're expect a wild west "just edit files on the server and you're good to go", expect push-back from your modern, professional, PHP developers :)

[+] mmmm|11 years ago|reply
Yes, and even more so with https://envoyer.io/ - according to the website a Laravel product.
[+] cweagans|11 years ago|reply
Nobody uses FTP for deployment anymore, but the idea is still the same: just get the file to the server.
[+] ing33k|11 years ago|reply
you can still do that.
[+] 0x0|11 years ago|reply
Any thoughts on how this will compare to Silex?
[+] pearjuice|11 years ago|reply
If Lumen can use all Laravel its components, can't Laravel use Lumen its routing engine or whatever makes it that fast? What's the key difference that Lumen is considered "fast and micro" over a standard Laravel installation?
[+] EGreg|11 years ago|reply
I'm sure this is great, but can I see some benchmarks?

I think many frameworks allow you to include the "basic" subset of the framework, without running all the usual Inversion of Control bootstrapping.

[+] evoratec|11 years ago|reply
Lumen is not micro, is a Slim-Laravel.
[+] sneak|11 years ago|reply

[deleted]

[+] ceejayoz|11 years ago|reply
Anyone still hating on PHP in 2015 is doing it wrong.
[+] adaml_623|11 years ago|reply
Really the biggest drawback to PHP is the lower salaries
[+] mildweed|11 years ago|reply
Market salaries are for rank and file coders. Build something that's wildly successful, and it won't matter what the language was.