- Add this repository into composer.json;
"repositories": [ { "type": "vcs", "url": "https://github.com/Urbanproof/wp-coding-standards.git" } ],
- Set stability requirements (necessary beacuse of the roave/security-advisories-package):
"minimum-stability": "dev", "prefer-stable": true,
- Require the package:
composer require --dev urbanproof/wp-coding-standards
This is a configuration file for the PHPCS. Create phpcs.xml
- file into your project root directory, and add following lines:
<?xml version="1.0"?>
<ruleset name="PHPCS Configuration">
<rule ref="UWPCS"/>
</ruleset>
Extending the ruleset is higly recommended, as it is very hard to predict exact loactions, text domains etc, so this ruleset comes without them.
<?xml version="1.0"?>
<ruleset name="PHPCS Configuration">
<file>singular-php-file.php</file>
<file>or-a-directory/</file>
<rule ref="UWPCS"/>
<rule ref="WordPress.WP.I18n">
<properties>
<property name="text_domain" type="array" value="your-text-domain-here" />
</properties>
</rule>
</ruleset>
- Run automatically before each commit with my PHPCS-pre-commit git-hook
- Run from command line;
vendor/bin/phpcs
- Integrate into your IDE
- Tested only with VS Code using this phpcs extension
- Note that you might have to restart your IDE before PHPCS is detected
- IDE complains that it cannot detect PHPCS
- It happens, try restarting your IDE
- Feel free to submit an issue