In this tutorial, you will learn how to add WordPress Coding Standards in PHP_CodeSniffer.<\/p>\n\n\n\n
WordPress Coding Standards have the ruleset of PHP_CodeSniffer<\/a>. The ruleset is a set of sniffs that looks for things that are wrong and tells you about them so that you can fix them. So if we go to GitHub and look up the WordPress Coding Standards<\/a> and navigate to it, we find the ruleset<\/a> having a bunch of instructions for PHP_CodeSniffer to follow. Now ruleset tells PHP_CodeSniffer what to do.<\/p>\n\n\n\n To get this ruleset on your computer you have to use git so I am assuming that you have already installed git on your computer and we will install it as a standalone set so you can use it globally. Now copy & paste the following command which cloned the master branch and we will put it in wpcs<\/strong> directory on our computer. In my case, I am on my D Drive<\/strong> and I have a special directory in my D Drive<\/strong> called utilities<\/strong> so I will change my directory by using the window command cd<\/strong> and navigate to utilities<\/strong><\/strong> folder i.e.<\/p>\n\n\n\n and clone them. <\/p>\n\n\n\n Now we have to tell PHP_CodeSniffer to go and look at this ruleset and to do that we will run a command phpcs<\/strong> and set some configuration with –config-set<\/strong> specifically, we want you to point at a new path with installed_paths<\/strong> and the path where we cloned it i.e.<\/p>\n\n\n\n After run above command, we will get the following output.<\/p>\n\n\n\n Now if we type the following command and hit enter.<\/p>\n\n\n\n We will see that we have all of the WordPress Coding Standards available via the command line on PHP_CodeSniffer.<\/p>\n","protected":false},"excerpt":{"rendered":" In this tutorial, you will learn how to add WordPress Coding Standards in PHP_CodeSniffer.<\/p>\n","protected":false},"author":3,"featured_media":892,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[100],"tags":[98,101],"class_list":["post-832","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-code-quality-tools","tag-phpcs","tag-wordpress-coding-standards"],"yoast_head":"\ncd utilities<\/code><\/pre>\n\n\n\n
git clone -b master https:\/\/github.com\/WordPress\/WordPress-Coding-Standards.git wpcs<\/code><\/pre>\n\n\n\n
phpcs --config-set installed_paths \"D:\\utilities\\wpcs\"<\/code><\/pre>\n\n\n\n
Config value \"installed_paths\" updated successfully;<\/pre>\n\n\n\n
phpcs -i<\/code><\/pre>\n\n\n\n