amphp/php-cs-fixer-config
Shared PHP-CS-Fixer configuration used across amphp projects. Install as a dev dependency, create a .php_cs.dist that returns Amp\CodeStyle\Config, configure the Finder paths and cache file, and run php-cs-fixer locally or in CI (e.g., Travis) for consistent styling.
Start by installing the package as a dev dependency:
composer require --dev amphp/php-cs-fixer-config
Then create a .php_cs.dist file in your project root (as shown in the README) using Amp\CodeStyle\Config. Configure the file finder to target src, test, and examples, set a cache file (e.g., .php_cs.cache), and return the config. This is the minimal setup needed to begin enforcing AMP’s consistent coding standards across your project.
--dry-run in script blocks (e.g., Travis, GitHub Actions), caching .php_cs.cache to speed up runs. Use --verbose --diff for informative failures.pre-commit hook (as provided in the README) to auto-fix staged PHP files only if php-cs-fixer is installed—ideal for avoiding breakage when contributors lack the tool../vendor/bin/php-cs-fixer fix -v before committing to ensure conformity. IDE integration (e.g., PHPStorm or VSCode integrations) can also leverage .php_cs.dist automatically.declare(strict_types=1) by default—ensure all files are compatible with strict types; partially compatible files may break after auto-fix.TRAVIS or equivalent env vars are handled—or better, use project-local caching (__DIR__ . '/.php_cs.cache') to avoid cross-run contamination.grep -e '^[AM]…', which only processes added/modified files at commit time; it won’t catch unstaged changes or changes to existing untracked files. Consider adding git stash support or switching to git diff --cached for broader safety.friendsofphp/php-cs-fixer:^3.5, rule sets evolve—even patch versions (e.g., v2.1.1 fixing str_increment) may change formatting. Pin to exact versions in CI if reproducibility is critical.Amp\CodeStyle\Config to override/add rules (e.g., ->setRiskyAllowed(true) for risky rules, or .include additional configs), but avoid diverging significantly—use consistency over customization.How can I help you explore Laravel packages today?