Blog
Oct 06

Why We Love Laravel

Here at Grenade we love Laravel and we think that you should too! Laravel has been the big buzzword of the PHP community over the last couple of years. Although the framework is still young, according to a recent survey by Site Point it was the most popular PHP framework at the end of 2013. If you haven’t tried out this superb framework yet, now is a perfect time to delve into it.

Here are some of the reasons why we love Laravel:

Up-To-Date Documentation

It is highly frustrating trying to learn a new technology that hasn’t been fully documented. Over recent years, this has been a big flaw with a lot of the new PHP frameworks. It seems to be the norm that framework developers expect early adopters to reverse engineer classes to fully understand their capabilities. This adds a giant learning curve and creates an initial lag in development as time is wasted on figuring out what is, and isn’t, possible. Documentation is clearly very important for developers. From the get go, one of Laravel’s goals was to offer up-to-date and useful documentation, paving the way for a much smoother transition to adopting the framework.

Artisan

Artisan is the command line interface used by Laravel. It makes performing tasks a lot quicker and easier. A good example of where Artisan really becomes useful is when one needs to create a new controller. A developer simply needs to type 'php artisan controller:make ControllersName' and Laravel will create a file with a skeleton of the controller. There are many other useful commands so we suggest running 'php artisan list' from terminal and familiarising yourself with what else is available.

Composer

Laravel makes use of Composer to manage its dependencies on an application level. Unlike PEAR, Composer manages dependencies on a project by project basis. Amongst the benefits of this are that future applications are not restricted to using old packages simply because previous applications made use of them. Because Laravel supports Composer, there are literally thousands of packages available on Packagist that you can add to your application.

RESTful Routing

Laravel can distinguish between the different REST HTTP methods (GET, PUT, POST, DELETE). This allows for the development of controllers in a RESTful way. For example calling the GET method on the URI:Users might call the get_users() method and return a list of users, while calling the POST method on the same URI would call the create_user() method and create a new user based on the passed values. This speeds up development time considerably when coupled with a Javascript framework such as Backbone.js.

Database Migrations

Version control systems such as GIT have made managing large development teams a lot easier. However, a big problem that still exists today, is synchronizing the current database. This usually involves sending SQL update files to other team members. Laravel addresses this issue with its database migrations. Database schemas and updates are kept as code within the code repository. To update a database structure all that team members need to do is run the 'php artisan migrate' command and this will automatically synchronize the local database structure. When creating new schemas and updates, a rollback condition can also be added. This is useful for rolling back changes as well as testing different versions of database structures.

Eloquent

Eloquent is Laravel’s ORM implementation. Eloquent uses a very simple, expressive syntax to get the job done. It is definitely one of the best implementations of ORM that we’ve seen. Using certain standards, such as a primary key column for id, a developer is able to rapidly build applications as the grunt work is already taken care of. Eloquent makes use of static methods so accessing objects is quick and easy. For example, retrieving a post would look something like this:

$post = Post::find($post_id); -> Simple, fast, and to the point is what Eloquent is all about.

Filters

By using filters you are able to run a special filter method before or after a routing request. A good example of how this would be useful would be to check if a user is logged in before performing a routing request. Filters are kept in a separate file which keeps your controllers clean. Once you understand the ins-and-outs of filters you will most likely learn to use them to great effect in your applications.

It Makes PHP Fun Again!

It wouldn’t be an exaggeration to say that using Laravel has made coding the most fun that we have had in ages. Laravel takes care of a lot of the grunt work that goes into application development, leaving you to concentrate on what’s really important in your application. The Laravel community is huge and growing everyday, so you’ll never feel alone, and there is always someone to ask over at StackOverFlow.

And those are some of the reasons why we love Laravel at Grenade. Do you use Laravel? Are there any other features that we left out? Please feel free to leave a comment below.