wp-coding-standards/wpcs
WordPress Coding Standards for PHP_CodeSniffer (WPCS) provides PHPCS rulesets and sniffs to enforce WordPress PHP style, best practices, security, and documentation guidelines. Install via Composer and run PHPCS to lint WordPress themes, plugins, and projects.
Install the package via Composer as a dev dependency: composer require --dev wp-coding-standards/wpcs:^3.0. The package auto-registers with PHP_CodeSniffer via the Composer PHPCS plugin. Run checks using vendor/bin/phpcs --standard=WordPress path/to/code. Start with the WordPress standard (includes all sniffs), then consider narrowing to WordPress-Core, WordPress-Docs, or WordPress-Extra as needed. For most teams, using --standard=WordPress with CI integration is the minimal viable first step.
Integrate WPCS early into your development workflow: configure a phpcs.xml.dist file in your project root to define your ruleset, ignore paths (e.g., vendor/), and sniff-specific settings (e.g., custom path prefixes). Use --encoding=utf-8 for multibyte-safe analysis and pipe output to tools like phpcs-reporter for reports. In CI, run on pull requests using GitHub Actions or similar with a matrix build (e.g., PHP 7.2–8.5) to catch compatibility issues. Combine with PHPCompatibilityWP for cross-PHP-version checks, and configure VariableAnalysis to detect undefined/unused variables. For IDE integration, use VS Code + PHP CS Fixer or PHPStan extensions configured to point to vendor/bin/phpcs.
composer global) are officially supported since v3.0—avoid PHAR or PEAR.phpcs.xml are resolved from the file’s directory, not where you run the command—use absolute paths for consistency in CI.phpcs -i to list installed standards; if missing, run composer dump-autoload.WordPress.NamingConventions.ValidFunctionName) are highly configurable but undocumented in the main README—check the wiki page for customizable sniff properties for overrides.esc_html(), esc_attr()) but doesn’t catch edge cases like wp_kses_post() misuse—combine with static analysis (e.g., PHPStan) for full coverage.--parallel=8 to speed up large codebases, and exclude heavy sniffs (e.g., WordPress.WhiteSpace.PostConditionSpaces) in CI if latency is critical—re-enable selectively during PR reviews.How can I help you explore Laravel packages today?