Wednesday, June 1, 2011

Codeigniter Versus Yii - my thoughts

Codeigniter versus Yii, now this may open a real can of worms, as most comparisons do, but I have used both and have to come to the conclusion that whilst Yii is probably that slightly more polished, Codeigniter is going to be my framework of choice for next few years to come when developing websites in PHP.

Let's take a look at Codeigniter, it's easy to learn, easy to grasp and now that it has been upgraded to version PHP5 only from version 2 onwards, much more future proof. I also really like the way that you can really, really customise it to do your bidding. No need to use the command line to get it up and running and it will run with a very small footprint. You can also cache the hell the out of it at multiple levels to squeeze every little bit of performance out of it, take a look here for a detailed look at this.

Now let's look at Yii, completely object oriented and its major, major advantage - The CRUD generator. My goodness, this saves you time, lots of time. You create your database, design your schema and bang the Gii tool produces (as if by magic :)) your create, read, update and delete pages. No mucking around no writing SQL, it's all done through the (Rails inspired) Active Record Pattern - it's fair to say I fell in love with this almost straight away, I couldn't believe how easy it was to create this code. And this is what got me thinking...

I like Codeigniter for its flexibility, the way you could use both an active record pattern or traditional SQL, You could keep your database results in arrays or as standards objects, they leave it up to you. But I wanted, no, no... I needed a CRUD generator after experiencing the wonders of the Gii tool. As a freelance web developer in Lancashire (I know this sounds cheesy) time is money, so I scoured the web for one and I found a couple out there and none really lived up to my expectations, one was particularly good, but didn't really suit my needs. Like I said, I liked Codeigniter because of its flexibility, so I decided to bite the built and create my own CRUD generator for Codeigniter. Yeah, sure it was going to take a little bit of development time, but the time saved will definitely outweigh the initial outlay and it does, plus as my CRUD tool was my own, I could tweak and make changes very easily. Now, when creating large projects, creating new sections is not the chore it once was and now leaves me more time to make the other, more unique features, just right.

The main point that many people raise when they compare the two frameworks is the way that Codeigniter is not truly object oriented, whilst Yii is much more pure in its implementation. I suppose this is true, but when I create applications that are large, I need to know that I can hack away at them very easily and tune them to my specific needs and it is for this reason above all else that Codeigniter remains my PHP framework of choice.

When I first set out developing websites using PHP, I though this was the language I would use forever when it came developing websites. I als felt like I would never, ever use a framework as how could using some else's ideas and code be of any benefit to me, when I have wrote my own application. Not only is the code battle ready as it has been through countless improvements through being used in the community, it also oipens up your mind to new ways of thinking. I learnt to use Codeigniter first and Yii second, but there are things used in Yii, that I will and have ported over in to Codeigniter, the way Yii authenticates users for example, is a great way of accomplishing this task.

It's like I have mentioned before in other posts, do not do what other people tell you should do. Sure take on board what other people have, but stick to what you are comfortable with using as it is you that is creating the application and not them.

Labels: , , , ,