John Main Logo

John Main

Code. Design. Hosting. Maintenance.

May '13

I’ve had cause to learn to use Laravel 4 for a new project I’m working on and I have to say, I’m very impressed. There are many great tutorials out there so I won’t go into details about the syntax, but the philosophy behind it is really worth talking about.

It’s built around the idea that most frameworks include a whole host of features that, while all useful in their own ways, won’t all be needed for every site you build. So the basic Laravel is very lightweight out of the box and uses Composer to manage and install any dependencies needed for your particular project.

Laravel comes with Artisan, a command line utility that provides a great set of functionality and shortcuts, such as generating controllers and models, creating and running migrations and regenerating the autoload scripts. If you’re familiar with Ruby on Rails you’ll see a lot of similarity with the Rails command line tool.

Laravel’s ORM is called Eloquent is and is the most powerful I’ve used for PHP. The support for migrations and seeding is well thought out and easy to use, the relationship management (has many, belongs to etc) is excellent, and it will even handle pivot tables for you without the need for them to have their own models. While it doesn’t have support for building models from an existing database, there are many tools out there that will do the job for you.

If you want more low level control of your database, Laravel’s query builder, whilst reminiscent of Doctrine, has very clean syntax and allows you to construct complex queries in a readable and logical format.

I could go over many many other aspects of Laravel, such as the incredibly clean Blade templating, the routing engine that is so advanced that you can do away with controllers for many applications and the built in Swift Mailer integration but the best recommendation I can make is for you to have a go yourself. There have been a great many ‘next big things’ in PHP that have turned out to have little staying power, but I truly believe that Laravel will have a profound impact on the PHP community, and show us all a new way of approaching our projects.