The following are a set of best practices for coding in PHP specifically. This is meant to compliment and extend the general programming principles.
- Read through PHP The Right Way, which contains so many point of best practice. Particularly useful for their advice on security and caching.
- Try to stay on the latest version of PHP, and upgrade early when new versions come out.
- Use PHP coding standards from the FIG, PSR-0, PSR-1 and PSR-2 to inform your use of syntax, class names, namespacing and file structures
- Where you can write DocBlox before class, function and method declarations specifying at least the author name
- Use elements of the SPL wherever possible, particularly for exceptions
- Code to an interface
- Try to use Composr and Packagist for dependency management
- Try to use xdebug remote (if you can set it up) rather than doing vardump or printr debugging
- Remember, PHP is a product of the free software community. Try to be a good citizen by open sourcing your own code or contributing back to existing open projects