PHP Coding Standards - Best Practices To Use

I am working on a large project in my company Astec in we decied that we will be using Codeiginter for the MVC framework to develop a web application. Before this project, we never had any PHP coding standards defined, so our source code was mostly very caotic to look at. We wanted to do this project the right way so we wanted to use some standards to make sense out of everything.


When we started preparing the development plan we decided that we want to apply some kind of simple coding rules to our code so we can understand each other when it comes to code. So we started searching for PHP Coding Standards that were both easy to implement and use and on the other hand had all the needed rules.

Where did I found PHP Coding Standards?

In the process of searching for the best PHP Coding Standards I came accross a very interesting blog post written by Fulgencio Sanmartin on his blog (by the way, thanks for the post Fulgencio :D).  His PHP coding standards are based on Zend Framework PHP coding standards.


Why coding standards? In big projects, in any project, they’re essential: understandeable, much easier, solid code. Perfect, mandatory for a team. The objective is to have all decisions documented, choices and standards that I will stick on when developing. Important thing is not to follow these guidelines, but to follow a set of them, whichever. It can be PEAR as this guy. My coding standards are based on Zend Framework Coding Standard for PHP, but some are mine. The result follows.

You can read the whole blog post on Fulgencio Sanmartin blog: PHP coding standards.


We ended up with a modification of the above PHP Coding Standards, and I must admit they are really simple to follow and produce very “readable” code as result. I was also looking to implement a PHP code sniffer to codeiginter so our code would be checked automatically as we work and found a great PHP script called PHP_CodeSniffer that does just that. It was written by Thomas Ernest and it can be found on Github at