yiisoft/yii2-coding-standards
The PHP_CodeSniffer coding standard used by Yii2 core and official extensions. Based on PSR-12 with documented Yii-specific exceptions, it lets you check and automatically fix PHP code with phpcs and phpcbf via the Yii2 ruleset. Requires PHP 7.4+ and PHP_CodeSniffer 4.0.2+.
yii coding-style command. It supports a decision like "adopt one automated style gate across all PHP services" — but only if the decision includes Yii2 code, because the rules encode Yii2 conventions, not Laravel's.laravel/pint (PHP-CS-Fixer based) or a thin custom phpcs.xml — this package does not replace either./legacy-yii/ directory only; editor/PhpStorm inspection profile for the handful of engineers still touching Yii2 services; contributor guidelines for any open-source Yii2 package the company maintains; a cheap pre-commit hook that ends style nitpicks in code review.Adopt when:
--standard=Yii2), not a new tool; the only real setup cost is the dealerdirect/phpcodesniffer-composer-installer allow-plugin permission under Composer 2.2+.Look elsewhere when:
$request, Blade files — as violations. Use Laravel Pint for formatting and Larastan/PHPStan for correctness. Layering this on top creates override debt with no payoff.phpcs --standard=PSR12 does that; the Yii2 delta buys you nothing.phpcs.xml with explicit exclusions and documenting every override; that file becomes a small permanent artifact.For executives (one paragraph): "This is a free, no-infrastructure way to automate PHP code-style checks for the Yii2 code we still own. It turns style disagreements into a machine check at pull-request time, which shortens reviews and makes the legacy codebase easier for new engineers to read while we migrate off it. It is not a quality or security tool and it changes nothing for our Laravel code, which keeps its existing formatter. Cost: zero licence, roughly a day of setup and a small config file to own. I am recommending it only for the Yii2 scope, not as a company-wide standard."
For engineering (the honest version): "It's a PHPCS ruleset — PSR-12 with Yii2's deltas — plus a yii coding-style command. Install as a dev dependency, point PHPCS at the Yii2 directories only (<exclude-pattern> everything Laravel), and run it in CI in warn mode first. Expect false positives on anything non-Yii2; don't fight them, scope them out. It complements, and does not replace, Pint or PHPStan — separate tool, separate job in the pipeline. If the deltas annoy us, forking the ruleset is a few files of XML; there is no lock-in."
Framing to avoid: don't present this as "a Laravel/PHP package we should adopt." It is a Yii2 artifact. The credible pitch is narrow — keep what we still run on Yii2 clean and reviewable, cheaply, while we leave Laravel's tooling alone. Anything broader will be correctly challenged in review.
How can I help you explore Laravel packages today?