yoast/yoastcs
Yoast Coding Standards (YoastCS) provides Composer-installable rulesets for PHP_CodeSniffer plus PHP Parallel Lint, bundling Yoast sniffs and selected external standards (including WordPress). Use it to enforce consistent code style and quality in Yoast projects.
Strengths:
laravel-wordpress). The WordPress ruleset aligns with WordPress VIP standards, which are often adopted in high-scale Laravel-WP integrations.Threshold report enables CI/CD gatekeeping (e.g., blocking merges if errors exceed YOASTCS_THRESHOLD_ERRORS), which is invaluable for Laravel’s iterative development cycles.Gaps:
^3.0.0@alpha) may clash with Laravel’s stable PHP version requirements (e.g., 8.1+). Requires minimum-stability: "dev" in composer.json.php artisan yoast:lint). Would need custom Artisan commands or Git hooks.dev dependencies via composer require --dev yoast/yoastcs). Automatically registers with PHP_CodeSniffer.vendor/bin/phpcs --report=YoastCS\Yoast\Reports\Threshold. Example:
# GitHub Actions
- name: Run YoastCS
run: composer check-cs-thresholds
WordPress.WP.GetMetaSingle sniff may conflict with Laravel’s wp_ prefix conventions (e.g., wp_get_post_meta). Requires .phpcs.xml.dist overrides.parallel-lint --exclude vendor or agent-specific optimizations.SlevomatCodingStandard.Arrays.ArrayAccess). Pair with interactive training (e.g., PHPCS --generator=Text docs).PHPCompatibilityWP may flag Laravel’s polyfills (e.g., array_column in PHP 7.4). Requires minimum_wp_version tuning in .phpcs.xml.dist..phpcs.xml.dist or create custom sniffs.<arg value="--exclude=app/Providers,resources/views"/>
YOASTCS_THRESHOLD_ERRORS) be project-specific (e.g., 0 for core, 5 for features) or team-wide? Answer: Start with team-wide defaults; allow overrides via environment variables.--exclude vendor and consider caching (e.g., GitHub Actions actions/cache).--diff for pull requests) and pair with autofix scripts (e.g., phpcbf for warnings).laravel-wordpress).php-parallel-lint defaults to 4 processes; increase to 8 for CI).FROM laravel:8.1 + yoast/yoastcs:^3.0).composer require --dev yoast/yoastcs in a staging branch.vendor/bin/phpcs --standard=Yoast --report=full app/ --exclude vendor
array_column usage).YOASTCS_THRESHOLD_ERRORS=0).YOASTCS_THRESHOLD_WARNINGS=5)..phpcs.xml.dist to:
minimum_wp_version (e.g., 6.0 for Laravel-WP hybrids).<config name="minimum_wp_version" value="6.0"/>
<exclude-pattern>*/Tests/*</exclude-pattern>
| Component | Compatibility | Mitigation |
|---|---|---|
| Laravel 8.x–10.x | ✅ Full (PHP 8.0+ supported) | Use minimum-stability: "dev" if needed. |
| WordPress 6.0+ | ✅ Full (PHPCompatibilityWP aligned) | Set minimum_wp_version in .phpcs.xml. |
| PHP 7.4–8.3 | ✅ Full | Test with php-parallel-lint in CI. |
| Homestead/Docker | ✅ Full | Match PHP version in containers. |
| CI (GitHub/GitLab) | ✅ Full | Cache vendor/ to reduce runtime. |
composer config allow-plugins.dealerdirect/phpcodesniffer-composer-installer true
composer require --dev yoast/yoastcs:"^3.0"
composer.json:
"scripts": {
"lint": "phpcs --standard=Yoast --report=full --exclude vendor",
"lint:threshold": "phpcs --standard=Yoast --report=YoastCS\\Yoast\\Reports\\Threshold"
}
.phpcs.xml.dist with exclusions.- name: Lint PHP with YoastCS
run: composer lint:threshold
env:
YOASTCS_THRESHOLD_ERRORS: 0
YOASTCS_THRESHOLD_WARNINGS: 5
phpcbf) can resolve warnings (e.g., spacing, heredoc formatting).How can I help you explore Laravel packages today?