zing/coding-standard
A Composer-installable PHP coding standard for PHP 8.0+ projects. Add it as a dev dependency to enforce a shared, consistent code style across your codebase and keep formatting rules aligned across teams. Install with: composer require zing/coding-standard --dev.
zing/coding-standard) is a PHP-CS-Fixer and ECS-based coding standard tailored for Laravel/PHP projects. It enforces consistent code style, improving maintainability and developer experience.INSTANCEOF, STRICT_BOOLEANS) and PHPUnit best practices, allowing fine-grained control over code transformations and linting.composer require --dev), avoiding runtime overhead.php-cs-fixer or ECS).php artisan make:test) and modern PHP tooling (PHPStan, PestPHP).STRICT_BOOLEANS) may require refactoring if the codebase uses loose boolean checks.INSTANCEOF) could alter logic unintentionally if not previewed.php_unit_data_provider_return_type) may flag legitimate patterns as errors.laravel/pint (though this package is stricter).instanceof checks).php-cs-fixer fix --dry-run and ecs check to identify violations.rector process --dry-run to preview transformations.STRICT_BOOLEANS) in feature branches.name: Coding Standard
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
- run: composer require --dev zing/coding-standard
- run: vendor/bin/ecs check src tests
- run: vendor/bin/php-cs-fixer fix --dry-run
husky + simple-php-unit to run checks before commits..php-cs-fixer.dist.php or .phpcs.xml files.ruleset.yml.ecs config:dump to inspect applied rules.| Phase | Action |
|---|---|
| 1. Evaluation | Run dry runs, assess violations, and estimate refactoring effort. |
| 2. Pilot | Apply to a single module (e.g., app/Console). |
| 3. CI Gating | Enforce in CI for PRs, then main branch. |
| 4. Pre-Commit | Add to local dev workflows (optional). |
| 5. Rector Rollout | Gradually enable Rector rules post-adoption. |
composer outdated + CI checks.zing/coding-standard:custom or fork the package.=== true instead of true").ecs sniffs list and php-cs-fixer --rules to diagnose failures..ecs.php:
return ECSConfig::fromPhpStormConfigFile()
->withPaths(['src', 'tests'])
->withIgnore(['vendor', 'storage']);
--parallel.--parallel and --cache flags to speed up runs.lint.yml, refactor.yml).| Risk | Mitigation Strategy |
|---|---|
| Build Breaks | Run dry runs in CI; use --fix mode for auto-correction. |
| False Positives | Whitelist exceptions in .ecs.php or .php-cs-fixer.dist.php. |
| Rector Over-Automation | Test transformations in a staging branch before merging. |
| Toolchain Conflicts | Audit dependencies for version conflicts (e.g., PHPUnit 12 vs. 11). |
| Adoption Resistance | Start with non-breaking rules; gather feedback before enforcing Rector. |
array_map vs. map, strict booleans)..ALL-CONTRIBUTORS.md section explaining the coding standard.How can I help you explore Laravel packages today?