LARAVEL

Laravel Four Test Drive

Share Button

At the time of writing this post PHP community is eagerly expecting Laravel 4 release that’s due on May 28th. We at Orange Hill are readily awaiting this release, not so new to us. Thanks to Jeffrey Way’s evangelical tutorials over at Net Tuts+ we were first drawn to this framework, and then (boldly if I may say) dived in.

No regrets. Beta was stable at that time, so there were no surprises. Here’s our experience in test driving L4:

We are a company that mostly uses our in-house PHP framework Photon CMS that facilitates easy and fast backend creation, and as a front end it basically serves up simple MVC structure. On occasions we did use other PHP frameworks; CodeIgniter and ZEND namely. For this particular project we felt that Photon CMS might not be the best weapon of choice.

Resource Controllers in Action

The project required complex admin panel that needed to be lightning fast so that site administrators don’t waist time entering content. AngularJS was chosen to speed things up in the backend. To feed this beast L4’s Resource Controllers saved massive amounts of time. To learn more about this feature have a look at this great RESTful API tutorial.

Blade Templating with Views Composers

Blade templating is nice and simple. It reminded me of handlebars.js instantly, so it felt like home from the start. Good thing is that Blade templates do not restrict you in any way if you choose to use plain and simple PHP code.

Site design features a lots of sidebars featuring top articles and such. Together with other repetitive site bits (Breadcrumbs, Menus etc.) this meant that a lots of common sub-template snippets needed to be created. We were used to feeding these snippets with data fetched on each site page load (e.g. from base controller all other page controllers extends from), or the controller dealing with pages that feature such snippets. What we liked in L4 is the ability to feed the sub-template view with data automatically whenever the sub-template is called. A code snippet like this one is easy to write & memorise the syntax:

View::composer('common.header', function($view) {
    $view->with('headerMenu', \Common::getHeaderMenu());
});

Actually, what’s great about Laravel is that it’s syntax is really sticky; it get’s in your fingers fast.

Eloquent ORM

We’ve tested ORM’s before, but never really emerged ourselves in using one. It always felt that whatever benefit we gain coding, that the frontend will become sluggish in return as a result of uncontrollable number of SQL queries. It made sense to give in this time, and it paid off. Eloquent ORM is carefully planned, nicely evolved ORM that handled every (and I mean every) query situation. I was surprised that we didn’t have to write a single query in a traditional way, as Eloquent was capable enough. And it saved time. Features like pagination are used on almost every PHP project, and in L4 it works magically simple.

Database Migrations & Schema Builder

One thing that a team of coders working on a website project needs is easy database sync. Our common practice was to shoot each other with database dumps, and as you imagine, this created holdup’s, inconsistency and other general problems. Now, if you stick to frameworks migrations plan you will basically achieve a “version control for you database” as stated in the L4 migrations docs. To write migrations you would use Laravel’s Schema builder, which is a breeze. All you have to do afterwards is run Laravel’s CLI with:

php artisan migrate

Unit Testing

Last but not least of the feature highlights is Unit testing. Laravel comes with PHPUnit . It’s easy to write out tests and setup test environment. L4 Unit testing documentation got this covered really well. Also you will find the Testing Laravel Controllers tutorial helpful.

Localization

Though Laravel has some neat features to handle i18n what I’d really love to see is translation of database content integrated with Eloquent ORM. Laravel’s i18n is built on top of Symfony’s, however, Symfony recommends using Doctrine Extensions Translatable Extension. Using Doctrine ORM doesn’t seem reasonable, so here’s room for somebody with time and knowledge to expand Laravel’s Eloquent ORM.

Laracon 2013 Amsterdam

Please note that a first EU Laracon is being prepared. More info @http://laracon.eu/2013/ . So far only the venue and date has been set (30-31 August 2013), so I hope to meet all Laravel EU-based enthusiasts there to learn & share about this cool, cool framework that for me brought a fresh breath of air in PHP coding.

Share Button
0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *