

You will see entries like WordPress, WordPress-Core, etc in it. It should show a list of coding standards followed by a comma. Test if the WordPress standards are configured properly or not by running the below command.

Add its path to the PHP_CodeSniffer configuration phpcs -config-set installed_paths /path/to/wpcsģ. Clone the WordPress standards repository git clone -b master wpcsĢ. So it is important that you already have installed PHP_Codesniffer on your system.ġ. It adds a set of rules in phpcs and phpcbf utilities so that it can check and format the code based on WordPress coding conventions. WPCS (WordPress Coding Standards) is most commonly used for that. While doing WordPress theme development or plugin development, it is very important to follow its own set of rules and coding standards. Phpcbf -version WordPress Coding Standards Once installed, make sure it is working properly by running test commands like this. C:\Users\YOUR_USERNAME\AppData\Roaming\Composer\vendor\bin\phpcs.batĬ:\Users\YOUR_USERNAME\AppData\Roaming\Composer\vendor\bin\phpcbf.bat On Linux or Mac OS, it will be like the below. Please follow the steps mentioned in the original GitHub repo for it.Īfter you install PHP_CodeSniffer, please note down the path of its installation location. You will need composer to install PHP_CodeSniffer on your system. The linting tool provided is called phpcs and the formatting tool provided is called phpcbf.

You can simply use it as a set of simple commands on the terminal. PHP_CodeSniffer is a set of tools that allows linting and formatting of code in one package and it’s an independent tool. To gain more knowledge on PHP Coding Standards (also called PSR), please check PHP-FIG website. These are good extensions but don’t provide a better solution for code sniffing and formating code using PHP Standards. Some of those are PHP Intelephense, phpfmt, and PHP Formatter.

While coding in PHP using VSCode, there are plenty of extensions that provide code formatting. Here I am going to show you how you can follow coding standards with PHP and format the code. It is one of the fundamentals of coding and is applied to every programming language. While coding, it is very important to follow specific coding standards and format the code to make it easy to read.
