PHP coding standards – the first steps
PHP coding standards
When I did write my first code, I did not know anything about PHP coding standards. My code was disgusting and very hard to read and edit. It was horror. Fortunately, that was many years ago and now have we many manuals and plugins helping us write clean and readable code.
Websites
PHP has a good community and this smart und helpful people did crate PHP standards. Since this time can we use so many great tools like "composer". This is a website then should know everyone PHP developer:
PHP Standards Recommendations
In first two chapters can you read how should look your code. That is very important to you and another programmers, who will work with your code in the future.
If you work with frameworks the standard may be different, so I recommend you check a framework documentation.
Books
The first book "Clean code" is a bible for programmers. Many developers know this book by heart. If you did not read this book… shame on you!
Of course, you mustn’t use all advice. Sometimes should you go own way, but many Martins tips can you help write good code.
The Second book is "Modern PHP". Author J. Lockhard is one of the founders "PHP The Right Way". Lockhard describes in a clear way, how look moderns PHP coding.
Tools
In PHP world has you two basically tools to checking your code syntax:
PHP Code Sniffer
Code Sniffer check if your code is complaint with PSR or frameworks standards.
PHP Mess Detector
In PHP Mess Detector can you set own rules like maximum number of arguments in functions or variables name length.
Both tools can you use with many IDE’s and editors, for example, VIM or PhpStorm.
At the end I recommend you see how to look popular repository on Github. You can learn many about clear code from other good developers. Good luck!
No Comment