No matter what language you write, clean code is always difficult, isn't it? So each community defines the coding convention for their programming language. Especially PHP, it is created without a real design. That is why the PHP code is too flexible and "crazy". Although PHP FIG is founded to help the community have some coding standards, a lot of existing projects still have their own unique coding standards. You may be uncomfortable if you have to change the work on a framework/library to an another one, I guess.
I started using PHP with CodeIgniter 2.x that follows snake-case style for classes, interfaces, methods, and so on. It doesn't look like really good I thought. Then I moved to Laravel 5.x and was excited about the style. It's much different from any PHP projects I had worked in. The code of Laravel framework is beautiful and easy to read. So, I decide to apply Laravel coding standards for all my PHP projects.
But when going through the Laravel core, I discovered the rest of PHP World with Symfony, Doctrine, and a ton of awesome libraries. They have different coding standards that take me time to read, understand, and customize or extend. I feel tired to practice all coding rules.
Everything has been changed since the day PHP CodeSniffer came to my life. It's unnecessary for me to remember all framework/library coding standards. I just need to know some important rules and the code format tool does rest things.
Additionally, I can create own standards too. You may try my package xuanquynh/php-codesniffer and give me some comments. :))
Not limit to PHP, with any programming languages, the developers should focus on features and remember just some important rules and let the code format tool do the rest things.
Happy coding everyday!
Be the first one to comment