Choosing the Best PHP MVC Framework – Part 2
In Choosing the Best PHP MVC Framework – Part 1 I discussed what I feel is necessary of a good PHP MVC Framework. So, I’ve spent a fair bit of time researching the various PHP MVC Frameworks and basically come the realisation that most of them aren’t all that great for one reason or another. For one, many clearly didn’t keep in mind the use of a PHP IDE like NetBeans or Eclipse PDT and hence their design resulted in poor (if any) support for intelli-sense. Because of this I’ve pretty much straight away discounted these frameworks as having to remember all the methods of an object and not have code completion is a real pain and really hurts productivity. Of the two more or less popular frameworks left were Zend Framework and Yii Framework. I found Zend Framework to be too general and as a result too heavy and slow… Zend Framework is really an enterprise framework that tries to be all things for all people and that’s nice, BUT you pay for it with performance and you can pretty much forget about using it without having at least a Virtual Private Server (or preferably a Dedicated Server) and OpCode Caching enabled. Even with OpCode Caching it’s still not the best performer. Yii Framework is a lot better from this perspective and feels a lot more natural and close to ASP.NET to which I’m quite used to as well. What I really dislike about Yii is the fact that it is really built with ActiveRecord in mind. Sure, you don’t have to use it, but then you loose many of the benefits that it offers. For example if you store language dependent data in a separate table then Active Record becomes a bit more of a pain. It is also a pain when you tend to aggregate a lot of data and in that case the whole Domain Model pattern doesn’t work all that great either and Table Module is far more practical. Having spent a lot of time implementing web applications and other database driven apps in .NET and PHP I have found more and more that Domain Model is really not the best option and a real skill is knowing how to build an app that’s easy to develop and extend. The use of ORM in pretty much all the frameworks is also something I don’t think of very highly, as they’re ultimately trading off performance and flexibility for bugs and pretty much having to learn another language. I really think that for heavily database driven applications the best option is NOT to use a pattern such as Active Record and to keep the data separate from the business logic that acts on it. PHP is particularly well suited to it with it’s use of associative arrays (although you do loose code completion support for fields as you would with untyped datasets in .NET, but that’s something most PHP developers are used to anyway). Furthermore, I tend to use only MySQL, so I don’t really see much point of having a database abstraction layer.
So, rather than using an existing PHP MVC Framework which pretty much forces you into concepts I fundamentally disagree with or don’t need like ActiveRecord, ORM, Database Abstraction, etc. I’ve decided to write my own minimalistic framework that will be lean and mean, yet logical and with support for what I need rather than what someone may or may not need/want and stuff that kills perforamance and takes away control over SQL from me as the developer.
I will be posting about how I intend to design this framework as well, which is probably more for my own benefit as writing stuff down helps me think it through.