Over the weekend I found myself evaluating new frameworks to use.
The current framework I am using right now for my projects is the Zend Framework. I like that it has a lot of components, hence some people call Zend more of a component library. Some of the components I like are Zend Form and Zend_Resource_Autoloader which makes it easy for me to load third party libraries. One problem I have been having with it though is it’s lack of a Dependency Injection container. Right now I still have to either manually inject dependencies or instantiate dependencies in the constructors of classes where they are needed. It works but I don’t like it it. I think it’s dirty.
I knew that the Symfony Framework has a Dependency Injection container already, not only that, it already has integration with ORMs like Propel or Doctrine built in, which is another must have feature on my list. Furthermore, unlike the Zend Framework, Symfony has a better documentation. This isn’t a deal breaker for me if I were to choose right now between them as I have pretty much figured out my way around the Zend Framework although if someone were to ask me and that person was starting from scratch, then Symfony would be something I would recommend.
Then there’s Laravel which a friend of mine has written a lot about. It has a dependency injection container and its own ORM as well and documentation that rivals Symfony’s. Oh wait did I also mention that it has REST controller both of which Symfony and Zend don’t have but it’s a must nowadays in the age of apps on multiple platforms. I also fell in love with it’s File API which seemed like it was easy to use.
In summary here are just the things I consider important in evaluating an application framework.
1. Support for Dependency Injection and AOP
2. An integration with an ORM preferably Doctrine or has an implementation like it.
3. Some form of REST support.
At this point, one might think that the simple answer is to go with Laravel right? After much thought I though not and as old saying goes, the devil is in the details.
The thing about Laravel was that it’s ORM was using the Active Record pattern. My issue with active record is that the record persists itself in the database like this $someRecord->save(). Well I could go on all day saying how it shouldn’t be there but that’s for another post. Another issue is its use of static methods with the File API. This is a big no no for me as static methods limit testability.
With Symfony, I get the integration with Doctrine 2, which does not use the Active Record pattern anymore as well as a dependency injection container. Plus, the REST plugin intrigues me as it somehow manages to slot seamlessly if for instance, you built your app as initially a web app but decide that you want to support other platforms as well through RESTful API. Then too, the documentation is just great. The only caveat however would be the learning curve required to learn the inner workings of another framework again.
This now, leaves me with the Zend Framework. It has no DI container, no REST controller that (there is but I have used it before and I think it’s just an abstract class with abstract methods and you actually have to echo json_encode($return); for it to return something). Furthermore, it has also no integration with Doctrine 2.
So what did I decide to choose? After much thought I chose something that I think some people would find crazy. Stay tuned.