Laravel – PHP Framework Review

Laravel is a relatively new PHP framework in the large number of PHP frameworks available.  It was first released in June of 2011, so it's a little over a year old.  Laravel is a free open source,  framework based on PHP 5.3 or better.

One might ask, why yet another PHP framework, when we have Symfony2, ZF2, CodeIgniter, Kohana3, Fuel, and Yii, among many others, all of which are fully implemented frameworks loaded with functionality?  Well, I'm here to tell you that Laravel is special, and the most exciting framework I've seen to date.

Laravel's rather long tag line reads, "Laravel is a clean and classy framework for PHP web development. Freeing you from spaghetti code, Laravel helps you create wonderful applications using simple, expressive syntax. Development should be a creative experience that you enjoy, not something that is painful. Enjoy the fresh air."

That's just enough gushy words to intrigue me to at least take a look under the hood, and every where I looked, I came away impressed.

Laravel was developed by one developer, Taylor Otwell. I like that, the alternative is to develop by committee like the new Zend Framework 2.  One developer is like a director on a film, it's his vision.

Taylor did it right.  All the syntax in Laravel follows the same format.  Once you get the feel for the syntax, you intuitively know how to write code, no matter where you are in your application.  All the code is descriptive of the functionality, but with short length names, thus reading Laravel code is easy and understandable, this makes the framework easy to learn as well.  Taylor writes, "Laravel is a PHP framework committed to elegance and simplicity.  Programming doesn't have to be painful. In fact, it can be enjoyable with the right tools. Laravel is one of those tools. Dig into its wonderful documentation to learn more."

Which brings me to documentation, Laravel has the best documentation of any framework I've reviewed, even better than CodeIgniter's.  There is also a book available, called "Code Happy" which is written by Dayle Rees, who writes like he's talking with you, and makes everything understandable.

All right, Laravel, has great documentation, great syntax, but what about functionality.  What's under the hood?

Autoloading of any classes in the models or  libraries folder.  You can easily map classes to the autoloader by directory, sub directory, individual class, and namespace bye, bye, all those includes.

An Event class with listeners and closures which can be used to extend the core code.

Routes with reverse routing, where you can create links to your routes.  Application logic can be created with restful controllers, or in your routes with closures.  Routes can have before and after functionality.

PHP Unit test for your application, and  Laravel has hundreds of tests built into the framework. So it is reliable from release to release, and one of the most stable frameworks available.

View composers, like dynamic templates, automatic pagination, and, if you want to use it, a built-in template language called "Blade" that looks a lot like "Mustache" to me.

On the database side, Laravel has one of the most advanced active-record ORMs built-in to the framework, called "Eloquent," which gives you complete control of your data and what is returned with your data.  I remember with Kohana3 having to decide which ORM to use with my application.  Laravel makes the decision easy.

Along with the ORM is a built-in query builder, called "Fluent,"that works across several databases, and uses prepared statements, which prevents any SQL injection.

A command line language, called "Artisan" uses the "migrate" command to allow you to create the database schema for easy migration to any database, set up the ORM, and roll back the schema and inserted data a step at a time for version control.

If this is not enough to wet your appetite, when you want to add your own, or other developers, code into the framework, it is easily done with what Laravel calls "Bundles".  Once added, Bundle classes are autoloaded as well.

There are quite a few Bundles already available that you can add to Laravel, including one called, "Bob" that will generate the skeletons for your tests and various other classes.

Finally, all of this is for not, if Laravel is as slow as Zend Framework 2, but it's not.  Laravel in an independent benchmark is faster then Yii, Kohana, and CodeIgniter, which means it is the fastest full stack PHP framework available.  What's not to like?

Laravel is available on GitHub, so it's easy to install and keep up to date.

If this review doesn't make you take a look for yourself, then you don't need a PHP framework.  Forget Zend Framework 2, and take a hard look at Laravel, you won't be disappointed.

Comments

Laravel – PHP Framework Review — 4 Comments

  1. I’ve been using Laravel for a few weeks now. First time I’ve really used an MVC approach therefore the learning curve on the whole was very steep. But it’s all starting to make sense now, and I’m glad I took the plunge with Laravel rather than any others. I still think there is a little way to go in the form of best approach documentation – ie when to to use routes rather than controllers, when to break away and set up helper functions, how to amend bundle migrations etc but it’s certainly a framework I’m going to stick with.