|« Working in teams with Visual Studio and Clearcase||Perceived value »|
Small comparison of PHP FrameworksOctober 11th, 2011
I’m working on a PHP web site and I want to add a user authentication component. In the past I’ve written hundreds of these things and couldn’t be bother to write the same code all over again. You know the story: create user table in the database, add a load of database table management web pages to create, modify and delete users, then add the concept of a logged-in user to each page. It’s a lot of work. Those of us in the “know” call this boiler plate code and it is basically a laborious distraction away from writing our application.
I thought I’d check out some of the PHP Framework tools available to see what there is out there that could handle this for me. This is by no means a comprehensive list. I wanted to briefly look at a couple and choose; I didn’t want to spend all day trying to pick holes in each one. I figured that for such a small requirement it wouldn’t take long to implement the user authentication. If one of my short list didn’t shape up then I could just swap it out.
My only goal is to find something that will handle users for me. The framework that gets me closest to this wins.
There is a handy web site called PHP Frameworks that lists the majority of the frameworks. It has a really handy table that describes which features are supported by which frameworks. The features it tracks are: PHP4, PHP5, MVC, Multiple DB’s, ORM, DB Objects, Templates, Caching, Validation, Ajax, Authentication Module, Modules and EDP.
The Akelos framework describes itself as a Ruby on Rails port for PHP. I’ve used Grails before. Although they can save you a lot of time, you lose the time benefits in trying to learn all the commands. One just seems to spend all of ones life trying to figure out why it didn’t work and hunting for bizarre error messages in forums.
There is a “Creating a blog in 20 minutes using the Akelos PHP Framework” screen cast. A Spanish guy with an unpronounceable name whizzes through the tutorial. It’s quite comprehensive but you really need to run through it with him feeling your way along with the application and trying different things. There are many commands to create controllers, models and views, but if Grails is anything to go by, there are a host of other things you can create which will slowly suck the life out of you! There just seems to be loads to do and read before you can do anything.
Verdict: Once bitten twice shy. Anything which uses convention over configuration requires you to learn all the conventions which are often not obvious or conventional. I don’t really want to spend the rest of my life doing this. For what I need this is too much effort and work.
Dingo on the other hand has a really simple website. This project works less like a framework which is all encompassing and more like a set of classes that can be slotted in. You need only learn and use the helper classes that suit you. Dingo is still an MVC framework but it is so unobtrusive you should be able to fit it in to an existing development. If you need a nice simple example of how an MVC system works then this is a really good starting point. Documentation is clear, the examples are straight forward and simple. The project probably doesn’t have a million options to fulfil everyone’s requirements but if you want to use the more general cases then you should be more than happy. There was several modules to help handle XML, pagination, Capcha, Sessions and user authentication. Reading through the project’s Twitter feed suggests that the project is struggling to find developers. It would be a real shame if development stopped on this project.
Verdict: I definitely liked this. It was what the Spring Framework is to JBoss. The project is still in it’s infancy (version 0.7.1 at the time of writing this) and there also didn’t seem to be much in the way of example projects, but it kind of doesn’t matter because what there is there should be enough to get anyone up and running.
The best introduction you could have is to watch the 4 tutorial presentation screencasts. Each one is 5 to 7 minutes and takes you from downloading the application to writing a Hello World program where the Hello World text is stored: in the page, in a template and then in a database. This application is also an MVC but unlike Akelos many of the steps have helper web pages to guide you through, rather than expecting you to remember all the options. The user interface helps with the setting up and configuration of Models, Views and Controllers. The Class Reference documentation looks generated and as a result it’s comprehensive and easy to navigate with a similar feel to JavaDocs.
Verdict: After watching all the videos I am raring to go. From the outside it has probably the same amount of features as Akelos or CakePHP but my fears have been allayed by a very good support web site and a set of accompanying books.
I did like Dingo but I’ve decided to go with Yii because it looks like I can just use it for a small part of my site and yet there is plenty of scope for it to grow if needs be. My next blog post will probably be along the lines of setting up a user authentication system in Yii. So watch this space.