Moving From Zend Framework to Laravel 4

Let me preface this blog with the following: I have been a programmer for the past 12 yrs and have used php for nearly 8 yrs, ZF1 for nearly 3 yrs (10+projects) and ZF2 since its inception. So, I understand the framework(s) quite well and have given it a fair amount of trial time.

About 2 months ago, I stumbled upon the Laravel framework. A couple of hours into studying Laravel, I had an epiphany : This is what all other frameworks should strive to be! Easy, Functional, modern and completely out of the way. While its CodeIgniter underpinnings are easily discernible based on the folder structure and config files, it is quite a radical departure in terms of the underlying code. Laravel 4 in particular embraces all prevailing best practices in the PHP world.

In comparison, both ZF1 and ZF2 are complicated, and require a steep learning curve. I kid you not, I was up and running with Laravel 4 in about 3 hours! (properly understanding my first “hello world” with ZF2 took me a week).
In my humble opinion, ZF2 is over-engineered, demanding more attention than the actual web application at hand. The reliance on (deeply nested) arrays for everything from route configs to parameters makes coding a chore. See, while arrays are speedy and flexible, they are a debugging nightmare. You get pretty much Zero IDE support (autocomplete, code completion etc). You have to remember verbatim all the required keys (I kind of got around this using netbeans code templates.But the templates became so many in number that remembering those presented a problem!).

Two projects later, I can confidently say that there is nothing that I can do in ZF2 that I can’t do using Laravel 4 (and in lesser time). The fact that L4 ties into composer/packagist means that pretty much any open source php project(on packagist) can be utilized in a Laravel project. In fact, L4 uses ‘monolog’ for logging, ‘swiftmailer’ for emailing and ‘symfony’ for the HTTP core and command line interface. All while providing a very ‘laravelesque’ approach to coding. There really are no limits. Very cool indeed!

Although I feel a certain closeness with ZF due to the sheer amount of time I spent with it, I feel the time is right to switch to L4 for future projects. I think L4 has done a LOT of things right, and deserves credit for it. The Eloquent ORM is very easy to work with. Routing in Laravel is an absolute joy! It does much of the heavy lifting when it comes to RESTful interfaces.
Form management is beautifully implemented. It is trivial to implement custom form/html controls.The DI mechanism is very expressive.So are Filters and Events. The Blade templating engine has an uncanny resemblance to the Razr engine used by ASP.NET MVC (which I really like!).
Although it looks like L4 uses an abundance of static methods, in reality it harnesses the __callstatic() php magic method to actually load objects from the DI container. The L4 command line tool “artisan” is also very well executed. Unit testing is very simple and works right out of the box (no lengthy setups required prior to running phpunit).

L4 has indeed improved my productivity quite dramatically 🙂


12 thoughts on “Moving From Zend Framework to Laravel 4

  1. Your writing make me belive again laravel is realy awesome. I shared it in several FB groups. I will request you to join the laravel fb group 🙂

    Happy Laravelling!

  2. I really would love to learn Zend 2, but frankly i just can’t, i spend more time focusing on documentation that actually coding with it, ZF1 almost made me cry in the bathroom questioning my career path, till i stumbled upon Yii, but i have been hearing an awful lot about laravel, i just assumed it’s another “framework”. but i think your article tempts me to investigate.

  3. Its interesting your opinions of ZF are so misleading given you claim to have so much expertise. With less years of experience than you claim to have had I followed ZF Quick setup took about 10min for me to have a hello world app, 1-2 hrs later I had a fully customized Bootstrap and full module/services driven app. After less than 6 hours I had a full functional Doctrine ORM driven Blog.
    You must be on another planet, what on earth are u on about when you talk about debug hell with arrays in ZF? How is that issue of yours anything to do with ZF? ZF is not tied to arrays for configuring, it is very flexible, not to mention your routing example being one of the utmost advanced configuration u will ever need to do, surely not needed by 95% users, certainly not hard to enable/configure services, modules, orm, ect which is more than most need to use.

    1. I am merely sharing my rationale on moving from ZF2 to L4 based on my work with both frameworks. I don’t see how anything I wrote is misleading.
      My gripe with using deeply nested config arrays (ZF2) is that all/most keys and values are strings (ex. ‘template_path_stack’, ‘config_glob_paths’ etc). So, there is plenty of scope for typing errors in the absence of any support from the IDE. Surely you must have run into this when using ZF2!

      If you are in fact super-productive with ZF2, more power to you! Bear in mind that I am not saying ZF is bad (I continue to maintain several ZF apps).. All I am saying is that at the end of the day I will have accomplished more with L4.

      1. On the contrary, i never experienced that type of issue in ZF at all, i guess it is because of the great Intelli-sense in NetBeans for ZF and my attention to detail perhaps.
        I dont understand why you continuously enforce you are restricted to using arrays… The recommended and most documented configuration i found is ini loading, not arrays, and even if i did use nested arrays i doubt they would cause enough frustration to even be worth mentioning to anyone…
        L4 is a good alternative, though perhaps it would have been less misleading to compare it to ZF and rather a framework more on its level like yii or kahuna because none of these L4 yii Kahuna ect are close to being a framework good enough for enterprise and with custom bootstrap and Zend_loader be responsive and powerful for any level/type of project…

    2. Are you sure you are talking about zf2 and not zf1? zf2 has no ini config files, all kind of things: routes, registering modules, controllers, view, etc is configured in arrays. How can a IDE look into string keys in order to suggest you the correct keyword? Also there is no bootstrap file in zf2. Try to build a zf2 full application and dump the $config array into the log and tell us what you see.

  4. I have come to a similar conclusion about L4 compared to ZF2. Laravel is easier (and, to be honest, much more enjoyable) to use and, more importantly, harder to screw up with due to the clarity and expressiveness of the syntax.

    But don’t let me convince you – how about we let the projects speak for themselves? I would encourage people to compare the ZF2 quick start pages with the L4 quick start pages. Interestingly, the second and third code block on the ZF2 quick start page is about editing arrays to wire up modules, not to mention the massive array further down that is used to configure the routing. Not cool people, not cool.

  5. You’re correct. I read 2 books in Laravel from Dayle Rees and the cookbook by Taylor Otwell. This is the best framework in PHP, it is very easy to learn when you understand OOP.

    I have also experienced Codeigniter but before I started in a couple of weeks, I made a thorough research and found out it was DEAD! Then ZF2 which gave me headache in learning. Now I’m laravel and I’m teaching this to my students. REALLY COOL!

  6. ZF2 was predominantly our preferred framework for development of custom web applications until we stumbled upon Laravel as well. We are an web development outsourcing company with clients always rushing us for completion and deployment. Things weren’t going fast with Zend. Moreover, skilled Zend developers are a rare find and training new developers with Zend took too much time which pretty much dented our costs.

    Switching to Laravel was the best choice. It’s a as feature rich and stable as Zend however takes an average developer much lesser time to get pro with it. Plus it increases the productivity by leaps and bounds. Laravel for life!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s