Discovering Laravel 4


We have already discovered Laravel, a powerful and flexible PHP framework that is easy to learn. On May 28th, 2013, the developers released version 4.

In this article, we will see what has changed compared to the previous one, what has been added and what has been abandoned.


Laravel has experienced a significant increase in its catchment area between the end of 2012 and in the first few months of 2013, thanks to a multitude of direct and indirect causes.

If on the one hand, it is to say that some frameworks have begun to know a first slight decline (CodeIgniter, for example), we must admit that Laravel has managed without problems to gain a significant slice of developers. A result obtained thanks to a simple syntax, a profitable learning curve, an active community and as icing on the cake several excellent publications directly from the programmers of the framework itself.

Also, in August 2013, in Amsterdam, the first official conference of Laravel, Laracon.


The first thing that catches the eye, talking about changes, is in the installation of the framework. In fact, from this version, Laravel makes use of the Composer support for the installation of all the necessary dependencies. For those who were not aware of it, Composer is a convenient dependency management tool that allows, through simple definitions, to download for a project all the necessary libraries (grouped into “packages”), creating in a certain sense its own framework from time to time.

Let’s see how to create a new project by installing the framework. All with a simple command line instruction.

Provided you have installed Composer (which can be downloaded from and Git, in fact, just use the command prompt and type:

composer create-project laravel / laravel folder_of_project

Within a few minutes composer will take care to download and prepare everything you need, starting from the dependencies up to the real framework putting in the specified folder (in this case “folder_del_project”) all files. Comfortable, right?

In any case, a “second mode” of installation is also available: in fact, it is possible to download the file package from the Laravel site and, at a later time, start the “composer install” command to download all the necessary dependencies.

A mode, this second, which can be particularly useful in the case of problems with Git.

If there was one thing that was missing (although easily resolved with a bundle) it was just a bookshop for sending emails. The developers, however, must have thought that this problem should also be solved when they decided to include Swift Mail as a “base” for sending emails.

Let’s examine an example of a proposed syntax:

Mail :: send ('emails.welcome', $ data, function ($ message)
    $ message-> to (' ',' John Smith ') -> subject (' Welcome! ');

We are recalling the “send” method of the mail class. Method that presents three parameters: a view from which to take the body code of the mail, a “data” object containing any data with which to view the view and, finally, a closure in which to specify all the details of the mail to send (recipient and object, in this case).

Here it is: the email is served without further instructions to be specified.


Lighten, optimize and speed up: keywords in the development of every day, perhaps in the context of large and heavy applications that have to perform equally heavy operations. Think of a lot of emails to send, or a huge number of records to be changed or many files to be moved.

Making them in the context of a user request is the first solution that comes to mind, of course, but it is certainly not the most effective.

Thanks to the Queues and a unified API system the problem is quickly solved, considerably increasing the speed of their applications.

Here, directly from the documentation, a simple request to queue an email:

Queue :: push (‘SendEmail’, array (‘message’ => $ message));
Nothing more immediate.


A developer knows how important documentation is: without a correct and clear guideline, working with serenity is practically impossible.

Also with regard to documentation, Laravel developers have not spared themselves: the Quickstart page, available at is a perfect example of how, in a single page, they can be explained all the fundamental (and more palatable) concepts of the framework.

Obviously it was also inaugurated a special section on the forum (three, to be precise) totally dedicated to this new version of the framework.

No problem, of course, for all those who still use the “old” version: all the documentation is now at

From “Bundles” to “Packages”

Laravel 3 offered a modular support to software development, through the use of “Bundles”: real applications within applications that, following the HMVC pattern, allowed to reuse the written code in a more efficient way.

On the occasion of Laravel 4, a further step was taken: why limit yourself to using code written specifically for Laravel, when you can use everything to extend its basic functionalities?

So here the developers have decided to give full support to the “Packages”, obtainable through Composer. Sometimes identifiable with projects linked exclusively to Laravel, sometimes identifiable with totally unrelated realities (Carbon and Behat are the two examples reported by the site itself).


Actually we could talk a lot more about Laravel 4: but this is just an introductory article and it was not easy to find all the really significant and more “obvious” news for both the more experienced and the first-time developer.

There would still be talk of the Facades, the development of the Packages in detail and still the security, unit testing and evolution of Artisan, the command line tool that has been extensively revised compared to its previous version.

For today we stop here: for any other information you will find everything you need on


Please enter your comment!
Please enter your name here