yiisoft/code-style
Coding style and quality tools for PHP projects from Yii. Provides configuration and presets to keep code formatting consistent and enforce standards across your repository, helping teams maintain clean, readable code with automated checks.
Start by installing yiisoft/code-style via Composer:
composer require --dev yiisoft/code-style
This package provides predefined PHP CS Fixer rule sets tailored for Yii projects. After installation, create or update your .php-cs-fixer.dist.php file to use one of its rule sets—typically Yiisoft\CodeStyle\Yiisoft::getRuleset(). Then run vendor/bin/php-cs-fixer fix to enforce consistency across your codebase. Your first use case will be automatically formatting newly written Yii controllers, models, or modules to match Yii’s internal coding standards.
.php-cs-fixer.dist.php and reuse it across all Yii-based repositories for consistency.$config = Yiisoft\CodeStyle\Yiisoft::getRuleset();
$config->setRules([
'phpdoc_summary' => false,
'no_superfluous_phpdoc_tags' => true,
]);
return $config;
php-cs-fixer to your CI pipeline to fail builds if code doesn’t conform—use --dry-run for validation-only checks.php-cs-fixer on file save using the config file, ensuring real-time compliance.yiisoft/code-style and PHP CS Fixer—mismatches cause silent failures or exceptions.Component inheritance patterns)—validate results carefully in non-standard setups.setRules() to retain base compatibility.--diff --dry-run -vvv to see why a rule changed code; this helps troubleshoot unexpected fixes (e.g., docblock adjustments).composer.json—this package uses semver, but changes to rule sets may alter formatting drastically (e.g., between minor versions).How can I help you explore Laravel packages today?