Programming today is essential with Coding Standards . The goal is to maintain the same style, so that by observing it you can easily interpret it.
What is Coding Standards?
The Coding Standards are rules of style when developing, which allow us a better reading and understanding of the functions.
It tries to establish the best ways to work in WordPress and it is also not only based on style but also on best practices.
Why is code-style important?
Even if you are working on a private project, the format of your code speaks volumes. And if you’re in a multi-developer environment, it says a lot more. Well thought out, well-styled code shows quality (even if it’s not good), while chaos breeds sloppy programming (even if it’s great).
Here are some reasons to pay attention to the style of your code :
- styled code is easier to maintain . You may know what is happening today, but what will happen a year from now? Taking the time to structure your work will save you hours later.
- Other developers don’t read your mind , so they won’t understand your chaotic code, or it will take a long time to unravel it. Ensuring as little friction as possible in communication is best for the project, and this can be facilitated by a standards-compliant format.
- Slightly less important, someone learning to code should be able to visit a website and learn something by looking at the source code . Standards often have inherent logic, so a viewer would be able to figure out what is going on. Adhering to the standards could help many developers who are beginning to learn to code the right way from day one.
- In many cases, good formatting helps maintainability. Many standards require that declarations and other blocks of code be spaced. Not clumping the code will make an “Error on line 267” message much easier to fix.
This is my process that I keep updated to configure Coding Standards on Mac. There are several ways to install it, the one I like the most and the one I expose is with composer. Who does not know it is a software for libraries based on php to integrate in your projects in a very easy way. It also allows a global installation, which is what we will do. Then keeping all the libraries updated is very easy with this command:
composer global update
Install Composer on MacOs
We took the following steps that have really worked for me. We open the terminal and execute the following commands:
curl -sS https://getcomposer.org/installer | php
And we move the composer.phar file to the binaries directory / usr / local / bin. Check that this folder is there before.
sudo mv composer.phar / usr / local / bin /
And we change its permissions:
sudo chmod 755 /usr/local/bin/composer.phar
We add .profile
nano ~ / .profile
And we add an alias to use it easily:
alias composer = "php /usr/local/bin/composer.phar"
We continue in the terminal: