PHP, PEAR, & Zend Framework coding standards

I’m all for standardization and standardizing procedures for long-term efficiency. However, up until now, where there were no “official” standards for something, I would make up my own or imitate what I thought was the nicest. One place where I’ve done just this was with regards to my coding styles for PHP – I had my own styles. Well, no more! I’ve finally decided to take the plunge and following the PEAR coding standards.

The most obvious & immediate advantage of this is that my code will have a uniform look & feel to it throughout – whether at home, online, or at work. Another important, though less immediate benefit is that I will be able to contribute my code into the PEAR collection should I choose to do so. Moreover, it would seem that PEAR is easily going to be the biggest player towards the standardization of PHP programming styles (with a possible exception being the Zend Framework coding standards which, at first glance, seem to be inline with those of PEAR). The Zend Framework standards go a bit further & attempt to dictate how your should actually be coding – and it would seem that their guidelines are reasonable & logical from a cursory glance.
I’ve already started converting the style of my codebase for Hidayah Online, however, the code is not yet completely PEAR-compliant. The added benefit of going through all my codebase is that I am also able to trim it quite significantly – I have a habit of commenting-out code that I no longer want to use, and this habit over time has resulted in rather bloated files. I have been able to trim a large portion of these whilst also removing files that were never used in the first place. In addition, I have removed several unused or deprecated functions, classes, and miscellaneous code that just doesn’t need to be there anymore. This exercise will really help to make the project more manageable and move from the hodgepodge of nearly unrelated scripts into an actual uniform application.

I’ll try to follow this up with a more analytical commentary on the PEAR & Zend Framework standards, including contrasting it with my own coding style as well as trying to discover if there are any conflicts between the two styles.

Leave a Reply

Your email address will not be published. Required fields are marked *