Archive for November, 2011

The Best PHP Framework

I searched for the best PHP framework for a while. I tried CakePHP, Zend, Yii, Symfony, and Codeigniter. Some of them frustrated me to the point that I was ready to write my own mini-framework. I think the problem with some of them, at least from my perspective, is that they try to do too much. Some were just poorly documented. Sure, you can find all the information you need to find about all the features, but they don't make it very easy. For this post, I want to compare two of the most recent frameworks I've worked with, Codeigniter and Symfony.

I use Codeigniter for all of my personal projects these days. Recently, I had to use Symfony for some other work I was doing. I can see positive and negative aspects of each system at this point, and this is an overview of their main differences.

First, I'll talk about Symfony. It includes two ORMs, Doctrine and Propel. I was using Doctrine. It relies heavily on the ORM as it should, but I found utilizing an ORM to be overly complex. This may be due to my own ignorance, but when using an ORM, you have to get into a different mindset. Most people would view the ORM as a feature. For me, it was unwanted. Symfony is a great framework and is used by many people. My distaste for it should not be a deciding factor in choosing your own framework.

However, I would like to point out other things about Symfony that I didn't like. First of all, the directory structure is overly complex, especially when your job is to maintain code that is already in place. You may find yourself looking at a page and going through 10 different files trying to find where the code is located. Symfony has a ton of plugins, many of which have auto-generated forms and templates. There are times that you won't find the code that generates the form and from what I saw, your only option is to override the plugin's actions and templates. If the code you're maintaining doesn't override the plugin, you will have to check cache files for the auto-generated PHP and then implement this in the override.

While we are talking about caching, I'll point out that this is a good feature and it's implemented by default in Symfony. During the development maintenance of a site, however, it gets on my nerves. So, you'll spend a lot of time clearing your cache from the command line. Symfony depends on command line usage. While I like using a command line in most cases, I don't want to be jumping back and forth between my IDE, command line, and web browser so much. Since Symfony auto-generates a ton of code for you through the use of the command line, I can see the advantage, but I prefer the Codeigniter way.

So, let me talk about Codeigniter and why I prefer it to all other frameworks I've tried.

First of all, it stays out of your way. It arranges your site into three folders, as I think it should, models, views, and controllers. You can then arrange your files in sub-directories under these main folders as you wish. So if you have a user system on your site, you can put all your views for that section under views/user.

While I'm on the subject of views, let me touch on Symfony's templates and layouts. It's actually a good system and cuts back on the amount of code one has to write, but it depends on yaml config files in various locations. I liked the idea, but hated the implementation. I much prefer having the view source where I can easily find it. In Codeigniter, I get all my data ready to send to a view, then load that view. In this view, I can load other views as needed. So if my page has a top navigation menu, I can just load that menu from within my view. This templating system works best for me, and I don't have to search through config files at various locations to find out where the HTML is located.

Finally, documentation is much better in Codeigniter. If you want to know how a library or helper works, their documentation makes it simple to understand. Symfony's documentation is terrible in comparison. There's a reference but it's just not that good. Plus much of the documentation you'll need is actually on the Doctrine site.

Symfony has many features that Codeigniter doesn't. Codeigniter is much easier to use, has the best documentation, and is much easier to maintain. These three things are why I prefer Codeigniter. Maintainability and ease of use are the two main reasons to implement a Framework anyway. Without these two things, one would be much better off using straight OOP PHP.

 

 

, ,

No Comments

Hard Drives and Rice

In 2008 there was a major rice shortage in the world. Prices surged, and people were hurt/killed. This year (2011) we had another rice shortage, except this time it wasn't a shortage. The world had a surplus of rice, yet the supply was cut off from the consumer. Governments refused to export rice, mainly from fear that they wouldn't have enough for their citizens, but some also stopped exports because they knew they could profit from a shortage under-the-table. Some government officials in Southeast Asia profited by selling their stockpiled rice at very high prices. By stopping their exports, they created a fake shortage. There was plenty of rice to go around. Yet many people couldn't buy rice for their family.

Recently I've been reading about the upcoming hard drive shortage. Thailand, one of the world's largest manufacturers of hard drives has been suffering from heavy flooding. This has created a shortage. There's no doubt about it. However, that shortage was projected to increase prices by around 10%. Instead, tech merchants started sounding an alarm that there was about to be a major shortage, and prices have jumped by as much as 180%. Many people I know are rushing to buy hard drives that they don't actually need, just to avoid paying much higher prices for them later. This is a terrible time to buy hard drives. Sure their prices will be higher for a few quarters but eventually they'll drop back down to what they are now. In fact, they'll probably plummet as soon as production kicks back in to top gear. There will be a huge surplus of drives as everyone realizes they don't really need as many as they bought. Merry Christmas, everyone!

, ,

No Comments

Couldn’t Load XPCOM

If you are like me, you like to use the latest plugins for Firefox (when you use Firefox). Things like Firebug have become a staple for my web browser usage. I also love using Debian as my OS, and the stable version comes with a much older version of Firefox (sans logos and with the name iceweasel). Unless you download older version of plugins, most of the time you'll have trouble installing the plugins you want.

The simple solution is to download and install the latest version of Firefox directly from Mozilla. There's not much of an install process. Just download and uncompress the file. You'll get a firefox directory, which I moved over to my home directory and proceeded to create shortcuts for on my desktop and menus.

If you are using the 64 bit version of the OS, you will quickly run into the "Couldn't Load XPCOM" error. It's obvious that it is a library issue but the error doesn't give you a big clue as to how to fix it.

Good news, the fix is extremely easy. You are lacking some 32 bit libs that are required to run the program.
Fix is by running the following as root or with sudo:

apt-get install ia32-libs-gtk

After that, you should be able to run Firefox. Enjoy!

No Comments