cline/coding-standard
Opinionated PHP-CS-Fixer + Rector presets for modern PHP 8.4+ projects. Enforces strict coding standards, naming conventions, and architecture rules, with custom fixers, PHPDoc wrapping, and optional legacy tag/header rules for incremental adoption.
Strengths:
@author/@version tags aligns with Laravel’s shift toward modern documentation practices (e.g., PHPDoc focus).Gaps:
.env files, or migration files, requiring manual exclusions or custom rules.php-cs-fixer with minimal configuration, ideal for new Laravel projects or teams adopting modern PHP.composer scripts or custom workflows.@author/@version tags may require migration scripts or team buy-in for legacy codebases.--dry-run.faustbrian) introduces single-point-of-failure risk; fork or contribution plan may be needed for critical updates.php-cs-fixer configurations.php-cs-fixer instances, or only new projects? How will legacy codebases migrate?.php-cs-fixer.dist.php overrides?.env) be documented in the team’s configuration?composer.json flags) to avoid monorepo conflicts?composer require and minimal configuration.php-cs-fixer in phpcs.xml.dist or .php-cs-fixer.dist.php.cline/coding-standard for PHP).composer scripts or custom workflows.Phase 1: Assessment and Pilot
php-cs-fixer rules: Compare current configuration with cline/coding-standard presets using diff or git diff.@author tags, custom naming) that may require migration scripts.Phase 2: Configuration Alignment
php-cs-fixer in composer.json:
"require-dev": {
"cline/coding-standard": "^3.4",
"php-cs-fixer/diff": "^3.0" // For dry-run comparisons
}
phpcs.xml.dist or .php-cs-fixer.dist.php:
<?php
return (new PhpCsFixer\Config())
->setRules([
'@cline-standard' => true,
'ordered_imports' => true, // Example custom rule
])
->setFinder(
PhpCsFixer\Finder::create()
->in(__DIR__.'/src')
->exclude('vendor')
->notPath(['tests/', 'migrations/']) // Exclude non-PHP files
);
->exclude(['resources/views/', '.env', 'artisan'])
Phase 3: CI/CD Integration
name: PHP-CS-Fixer
on: [push, pull_request]
jobs:
fix:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
- run: composer install --dev
- run: vendor/bin/php-cs-fixer fix --dry-run --diff --rules=@cline-standard
composer require --dev dealerdirect/phpcodesniffer-composer-installer
composer require --dev php-cs-fixer
Add to .php-cs-fixer.dist.php:
->setUsingCache(false) // For pre-commit hooks
Phase 4: Gradual Rollout
composer.json flags or repository labels to control adoption..env, and migrations by default; document custom rules for these file types.cline/coding-standard for PHP, or synchronize rules via shared config..php-cs-fixer.dist.php for team-specific needs.@author/@version tags via migration scripts.How can I help you explore Laravel packages today?