PHP Style and Best Practices

This is a list PHP coding style and best practices guides.

PHP-FIG

The ultimate source which most others are based on or recommend is PHP FIG (Framework Interoperability Group). These are their most important documents:

Other PHP style guides

Some PHP frameworks and companies publish their own style guides. Most of them are based on PHP-FIG, but may deviate on particular recommendations (e.g. case to use for function or variable names).

PEAR Coding Standards

Symfony

Clean Code PHP

PHP the Right Way on coding style

Code Igniter style guide

Flow Framework style guide

Procurios style guide - One thing I like about this guide is that they list their differences from PHP-FIG PSR, which they are based on. It also includes a list of good coding style books (below).

Coding style books

  • Robert C. Martin - Clean Code
  • Robert C. Martin - The Clean Coder
  • Martin Fowler - Patterns of Enterprise Application Architecture
  • Martin Fowler - Refactoring: Improving the Design of Existing Code
  • Steve McConnell - Code Complete 2
  • Eric Evans - Domain-Driven Design