Taylor Otwell 发布了 Laravel 家族的新成员 Lumen , 一个以速度为目标诞生的微型框架。
Lumen 算是一个精简版的 Laravel，针对速度优化了框架的加载方式。Lumen 包括 Laravel 的主要功能：Eloquent，缓存，查询，验证，路由，中间件和强大的 Laravel 服务容器，多余的功能需要自行开启。
PHP >= 5.4
Mcrypt PHP Extension
OpenSSL PHP Extension
Mbstring PHP Extension
Tokenizer PHP Extension
Lumen 1.0 是第一个正式版本，基于 Laravel 5.x，也称之为 Lumen 5.0.0 版本，现已提供下载：
更多内容请看这里： https://laravel-news.com/2015/04/lumen/ 。
Taylor Otwell 昨天发布了 Laravel 家族的新成员 Lumen , 一个以速度为目标诞生的微型框架.
Lumen 的来源, 为什么要创建这个框架?
当 Taylor 在开发他的新项目 Envoyer 的时候, 需要编写两个小服务, 分别使用了 Silex 和 Slim, 在此过程中发现两个框架有一些不足之处, 并且他喜欢 Laravel 的语法, 可惜对于这种小应用, 使用 Laravel 的话有点杀鸡用牛刀的感觉, 最终, Lumen 诞生了.
引用 Taylor 的话, 来看这个框架的定位:
I didn’t want to release something that was slower than the alternative options.
从此, 在 Laravel 的开发旅途里, 我们有了功能齐全的全栈的框架 Laravel, 也有了以速度见长的微型框架 Lumen.
lumen new lumen 和
laravel new laravel 产生的两个项目速度对比:
Blackfire 上的, 比较科学的对比:
Lumen 算是一个精简版的 Laravel, 针对速度优化了框架的加载方式, 多余的功能需要自行开启, 请见 Taylor 在 Laracasts 上的介绍视频 – Introducing Lumen
Lumen is a brand new PHP framework from Taylor Otwell designed for building lightning fast micro-services and API’s. When speed is a necessity, Lumen should be your first choice.
One of the neat things about the framework is you can still use all the Laravel features you love like Eloquent, caching, queues, validation, routing, middleware, and the powerful Laravel service container. Plus if you start your project with Lumen and eventually need even more power, moving to the full featured Laravel is a simple process.
To find out more behind the scenes I had a quick interview with Taylor about the project:
What made you decide to create Lumen?
When I was buildingEnvoyer, I wrote two small “micro-services” to support it. One of them is the post-deployment health checks. That is a small application that lives in three different DigitalOcean regions. I used Silex for that application; however, I had to re-research how to make a PDO database connection. I would have loved to just have a very small Laravel installation that I could use
DB::update out of the box.
The other Envoyer service is the “heartbeat” Cron monitoring. Since these URLs could be called every minute by hundreds, if not thousands of Cron jobs, I needed that to be very fast. So, I used Slim for that service. But, again, I had to setup some more robust error handling as well as database connections. I again would have preferred a small Laravel “light” installation.
That’s where the idea for Lumen was born. It took me three or four iterations of building the framework to find a solution that was fast enough. I was not going to release Lumen unless I could say it’s faster than Silex and Slim out of the box. I didn’t want to release something that was slower than the alternative options.
Where did the name Lumen come from?
Lumen is a play on the “Illuminate” components that Laravel utilizes. The Illuminate components are the individual pieces of the Laravel framework such as database, cache, queue, etc. So, first, I think Lumen sounds cool as a name. It’s only two syllables, instead of three like Laravel. That may sound crazy, but I think about that kind of thing and the mental images that are conjured up when you say the word. Of course, it also continues the tradition of “light” based names.
Being able to upgrade right into Laravel is huge. Was this the plan from the beginning?
Yes, and it’s really just a natural outcome of using the Illuminate components that make up the full-stack Laravel framework. Since we use those components, it’s easy to provide a really great upgrade story, and I feel like that is something missing from other micro-framework solutions. Since the Laravel eco-system now contains both a full-stack framework and a micro-framework that are “officially” supported, we can provide really great upgrade stories.
How were you able to get the framework so fast, while still keeping so many great features?
This is again due to the great convenience of the Illuminate components. Basically, all I needed to do was “glue” them together in a different way than a full-stack framework would glue them together. This means instead of maximum flexibility in the bootstrapping process, Lumen opts for maximum speed. The actual Lumen framework repository is probably only a dozen files or so. The rest is made up of the Illuminate components. This allowed me to flesh out the features of the framework very quickly, though it did take me three or four iterations to find a solution that was really, really fast while still providing very powerful features.
Lumen is surely to a big hit and I think the way you can easily move into Laravel is a huge long term benefit for not only Lumen but the whole Laravel ecosystem. To stay up to date with all the latest happenings on Lumen be sure and join theweekly newsletter.