- Is yiisoft/yii2-coding-standards a Laravel package?
- No. yiisoft/yii2-coding-standards is a PHP_CodeSniffer ruleset for Yii2 core and official extension conventions, not a Laravel package. It integrates at the tooling and CI layer only, so it adds no service provider, runtime hooks, or Laravel-specific rules. In a Laravel organization it is useful only for legacy Yii2 code or migration containment.
- How do I install yiisoft/yii2-coding-standards for a Laravel migration project?
- Install it as a dev dependency with composer require --dev --prefer-dist yiisoft/yii2-coding-standards. For automatic standard registration, allow dealerdirect/phpcodesniffer-composer-installer and install it as a dev dependency. Then reference the Yii2 standard in a scoped .phpcs.xml or run vendor/bin/phpcs with --standard=Yii2 against only the legacy paths. Do not treat it as a replacement for Laravel Pint.
- Which PHP and PHP_CodeSniffer versions does this Yii2 standard require?
- The package requires PHP 7.4 or newer and PHP_CodeSniffer 4.0.2 or newer. Those are minimums, not a guarantee that every modern PHP 8+ idiom or Laravel pattern will pass cleanly. Validate the ruleset against your actual code and pin versions in CI before enforcing it.
- How do I run phpcs with the Yii2 standard on only legacy Yii2 directories?
- Create a custom .phpcs.xml that includes the Yii2 standard only for the legacy Yii2 directories and excludes vendor, Blade, and generated files. Run it with vendor/bin/phpcs --extensions=php --standard=Yii2 path/to/legacy or point phpcs at your scoped ruleset. Keeping the scope narrow avoids applying Yii2 conventions to Laravel application code.
- Can phpcbf automatically fix violations from the Yii2 coding standard?
- Yes, phpcbf can automatically fix violations that the Yii2 standard supports. Run vendor/bin/phpcbf --extensions=php --standard=Yii2 path/to/legacy, then review the diff carefully before committing. Use it on a branch or in a pilot subset first because automatic fixes can still change formatting in ways your team needs to approve.
- Does this Yii2 coding standard conflict with Laravel Pint?
- Yes, expect friction if you mix it into the same enforcement layer as Laravel Pint. Yii2 rules can flag Laravel idioms, facades, Blade templates, and modern PHP patterns that Pint or Laravel conventions allow. Use separate commands, separate scopes, and ideally separate CI jobs so the two standards do not fight each other.
- Should I use this package for a new Laravel application?
- No, a new Laravel application should standardize on Laravel Pint plus PSR-12 and Laravel-specific PHPCS or PHPStan checks. This package is a Yii2 ruleset, so using it as a primary Laravel standard adds conflicts and maintenance burden without strategic benefit. Consider it only if you have a concrete legacy Yii2 or migration requirement.
- How should I handle CI enforcement during a Yii2-to-Laravel migration?
- Start with an advisory CI job that reports Yii2 standard violations without failing the build. Record false positives and rule conflicts, document allowed exceptions, then enforce only for scoped legacy paths. Assign an owner for triage and keep Pint or Laravel checks in a separate job so the standards remain isolated.
- What alternatives should I consider for Laravel code style instead of this Yii2 standard?
- For Laravel code, use Laravel Pint, a PSR-12 PHPCS ruleset, Laravel-specific coding standards, and PHPStan or Psalm for static analysis. Those tools align with Laravel conventions and are easier to maintain than a Yii2 ruleset. This package remains the targeted choice only when you must enforce Yii2 style in legacy directories.
- How do I retire yiisoft/yii2-coding-standards after the Yii2 migration?
- Define an exit criterion before adoption, such as removal of the last Yii2 directory or completion of the migration. Then remove the scoped CI job, delete the custom .phpcs.xml entries, and drop the Composer dev dependency. Keep a local ruleset wrapper while it is in use so upstream changes cannot break CI unexpectedly.