Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Yoastcs Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Yoast Coding Standards (YoastCS) is a Composer package that bundles opinionated code style and quality rulesets used across Yoast projects. It integrates with PHP_CodeSniffer (and related standards) and includes tooling like PHP Parallel Lint to help teams catch issues early and keep codebases consistent.

Install it globally or as a dev dependency; Composer will register YoastCS and its external standards automatically so you can enforce rules locally and in CI.

  • Provides the Yoast PHPCS standard with enforced errors and advisory warnings
  • Ships with Yoast-native sniffs plus selected external PHPCS standards
  • Includes PHP Parallel Lint for fast parse-error detection
  • Designed for repeatable runs via Composer scripts and CI pipelines
Frequently asked questions about Yoastcs
Can I use YoastCS for Laravel projects that aren’t WordPress plugins/themes?
Yes, but selectively. YoastCS includes WordPress-specific sniffs (e.g., `WordPress.WP.GetMetaSingle`), which you can disable in `.phpcs.xml` by excluding the `WordPress` ruleset. The core PHPCS standards (PSR-12, SlevomatCodingStandard) are still valuable for Laravel’s code quality.
How do I install YoastCS for a Laravel project?
Run `composer require --dev yoast/yoastcs` in your Laravel project. Ensure `allow-plugins.dealerdirect/phpcodesniffer-composer-installer` is enabled in your `composer.json` or globally. The package auto-registers with PHP_CodeSniffer, so no additional config is needed for basic usage.
Which Laravel versions does YoastCS support?
YoastCS is PHP-version agnostic but defaults to PHP 7.4+ rules. Laravel 10+ (PHP 8.1+) works fine—just test with `phpcs --report=full` to check for PHP 8.1+ compatibility issues. Disable `PHPCompatibilityWP` sniffs if targeting non-WordPress Laravel apps.
How do I configure YoastCS to work with Laravel’s CI (GitHub Actions/GitLab CI)?
Add a step to your CI pipeline using `phpcs` with the Yoast standard, e.g., `phpcs --standard=Yoast --warning-severity=0 src/`. Set `YOASTCS_THRESHOLD_ERRORS=0` to block merges on errors. For Parallel Lint, use `./vendor/php-parallel-lint/php-parallel-lint/parallel-lint . -e php --exclude vendor`.
Will YoastCS conflict with Laravel’s built-in PSR-12 compliance?
No, YoastCS extends PSR-12 (via SlevomatCodingStandard) rather than replacing it. Run `phpcs --diff` to compare violations between PSR12 and YoastCS. If conflicts arise, override rules in `.phpcs.xml` (e.g., relax `SlevomatCodingStandard.Arrays.ArrayAccess` for legacy Laravel code).
How do I exclude Laravel’s `vendor/` or `node_modules/` from YoastCS scans?
Use the `--exclude` flag with `phpcs` (e.g., `phpcs --standard=Yoast --exclude vendor,node_modules src/`). For Parallel Lint, exclude them via CLI options: `parallel-lint . -e php --exclude vendor,node_modules`. Add these to your `composer.json` scripts for consistency.
Can I use YoastCS locally in PhpStorm or VSCode?
Yes. Install the PHP_CodeSniffer plugin for your IDE, then configure it to use the Yoast standard. In PhpStorm: `Settings > Languages & Frameworks > PHP > Code Sniffer > Standard: Yoast`. For VSCode, use the `php-cs-fixer` extension and set the ruleset to YoastCS.
What’s the performance impact of YoastCS on large Laravel projects?
Minimal for most projects. Parallel Lint significantly speeds up linting by processing files in parallel. Exclude heavy directories (e.g., `vendor/`) and use `--parallel` with `phpcs` for further optimization. Test with `time phpcs --standard=Yoast src/` to benchmark.
How do I handle false positives in Laravel-specific code (e.g., Facade usage)?
Override Yoast’s rules in `.phpcs.xml` to ignore Laravel patterns. For example, disable `WordPress.WP.GetMetaSingle` for non-WordPress projects or relax `SlevomatCodingStandard.ControlStructures.ControlSignature` for Facade methods. Document exceptions in your team’s coding guidelines.
Are there alternatives to YoastCS for Laravel code quality?
For pure Laravel projects, consider `squizlabs/php_codesniffer` with PSR12 or `php-cs-fixer` for automated fixes. If targeting WordPress, `WordPress-Coding-Standards/WordPress-Coding-Standards` alone may suffice. YoastCS adds Parallel Lint and Yoast-specific sniffs, which are unique.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport