spiral/code-style
PER-2–based PHP CS Fixer ruleset for Spiral components. Install as a dev dependency, add a .php-cs-fixer.dist.php via the Builder to include project paths, run via composer scripts, and integrate checks or auto-fixes in GitHub Actions CI.
Install spiral/code-style as a dev dependency. Create a .php-cs-fixer.dist.php file in your project root using the provided Builder API to define paths—typically src/ and the config file itself. Run php-cs-fixer fix (via Composer scripts or directly) to apply fixes, or --dry-run to check style without modifying files.
composer require --dev spiral/code-style
# Create .php-cs-fixer.dist.php (see below)
php-cs-fixer fix --dry-run
<?php declare(strict_types=1);
require_once __DIR__ . '/vendor/autoload.php';
return \Spiral\CodeStyle\Builder::create()
->include(__DIR__ . '/src')
->include(__FILE__)
->build();
"cs:diff" and "cs:fix" to composer.json for local style checks and fixes.cs.yml, cs-fix.yml) for automated enforcement in PRs/Merge requests.scripts and GitHub Actions to enforce style before merge (via cs:diff) and auto-correct on demand (via cs:fix).->useRule(...) or ->exclude(...) after Builder::create()—e.g., .exclude('config/*.php') or ->useRule('nullable_type_declaration_for_default_null_value' => true).spiral/code-style uses php-cs-fixer/shim (v2.3.0+), so avoid mixing with standalone php-cs-fixer installs—conflicting PHAR versions cause silent inconsistencies.->exclude() (not manual ->notName()), but ensure paths are relative to the project root—__DIR__ expansions in builders can cause path mismatches if misaligned.@method in docblocks, no trailing commas in arrays, no spaces in $arr[ $i ] → $arr[$i]). Adjust only if absolutely necessary—deviations cause CI failures across teams.ReturnTypeWillChange-like notices or PHP 8.4+ in CI.--diff to audit changes before committing.How can I help you explore Laravel packages today?