The Advancing PHP Developer Part 1: Coding Standards

PHP Web development May 25th, 2008 by Eran Galperin

level upA question that I hear often is how can one evolve as a PHP developer? The answer varies and depends on the person's programming knowledge and experience. I will cover the topics I think are the most important briefly in this series, provide links and maybe expand on them in the future.

I will assume intermediate level PHP competency as this is where most developers end up. They are capable of developing small projects, but their code isn't of great quality and they waste time and resources solving the same problems again and again.

This guide is about improving:

  1. Maintainability
  2. Development speed
  3. Coding practices
  4. Toolset
  5. Deployment

Part 1. Coding standards

Why coding standards are important: Coding standards are all about improving maintainability and teamwork. High quality code should reveal its intention to competent programmers without relying on documentation, though any set of coding standards includes some documentation practices (my favorite are phpDoc blocks).

When I began to think about code as prose that should transmit its meaning rather than being merely functional, my code quality started to constantly improve. When you consider how code will look as well as work, you create code that is more readable and hence more maintainable and share-able (in a team setting).

Some languages, like Python, force the programmer to use a certain coding standards - which is why some love it and some hate it.

For PHP, I use the Zend Framework coding styles which I think are great.

Extra reference material:
Wikiepedia - Programming Style
PEAR coding standards
Professional PHP blog on coding standards
A list of coding style guides

Next up: Object Orientation.

If you liked this article you should follow me on Twitter and/or share below:
  • http://www.carltondickson.co.uk Carlton Dickson

    This is a really important point Eran, looking at other developer’s code is always tricky but even more of a challenge when their coding style differs so much to yours. Best thing to do at the beginning of a project is agree to follow a certain standard, it will make live easier if one of the developers leaves you team and you’re required to pick up their work.

  • http://www.carltondickson.co.uk Carlton Dickson

    This is a really important point Eran, looking at other developer’s code is always tricky but even more of a challenge when their coding style differs so much to yours. Best thing to do at the beginning of a project is agree to follow a certain standard, it will make live easier if one of the developers leaves you team and you’re required to pick up their work.