This is a short list of PHP hints to avoid common mistakes which I've seen through the years. Others have the same problems and probably already a solution. Remember every own code line in your project costs money and must be maintained. With the following 15 hints can you incredible improve your project quality!
E_ALL | E_STRICTas PHP
error_reportingand display errors/warnings and fix them. (development environment)
- Don't use
require_oncefor the include of your PHP classes.
- Use small modules instead a monolithic code base, they are easier to maintain and to test.
- Follow SOLID principle
- Publish your none business critical libraries on github.
- Use PSR 0/1/2/4 and PHPDoc comments
- Use PHP CodeSniffer to check your code style for PSR rules.
- You don't have to reinvent the wheel, use Frameworks to get things done.
- Use Composer for dependency management and autoloading of your PHP classes.
- Use Semantic Versioning
- Use dependency injection
- Use service locator
- Use service layer
- Use component exceptions for better exception handling
- Use continuous integration/inspection tools
If you already follow the 15 hints above, it's time to push yourself to the next level with my another article about Hexagonal Architecture, Domain Driven Design, Event Sourcing, Oh, My!. You know that performance matters, then have a look to PHP profiling tools.
Do you also agree with this or have you an other opinion? Please feel free to start a discussion.