- What is zing/coding-standard?
- zing/coding-standard is a Composer dev dependency that provides a ready-to-use PHP coding standard built on PHP-CS-Fixer, ECS, and Rector. It helps enforce consistent style and quality across Laravel and PHP codebases. Because it is installed with --dev, it does not add runtime overhead to your application.
- How do I install zing/coding-standard in a Laravel project?
- Install it with composer require zing/coding-standard --dev in your Laravel project. Then run the provided ECS and PHP-CS-Fixer commands, such as vendor/bin/ecs check and vendor/bin/php-cs-fixer fix --dry-run, to review violations. You can add the checks to CI or pre-commit hooks once you are satisfied with the baseline.
- Which Laravel and PHP versions does zing/coding-standard support?
- The package requires PHP 8.0.0 or higher, which aligns well with Laravel 9 and newer applications. Legacy Laravel 8 projects on older PHP versions may not be compatible. Check your composer.json platform requirements before adding it.
- What tools does zing/coding-standard use under the hood?
- It combines PHP-CS-Fixer for style fixing, ECS for coding-standard checks, and Rector for automated refactoring. Those tools let it cover formatting, linting, and controlled code transformations. The package exposes rule sets rather than requiring you to assemble every tool from scratch.
- Can I customize the coding rules for my Laravel app?
- Yes, the ruleset can be customized, but you should merge changes carefully because the package supplies opinionated defaults. Use ECS config dump or dry runs to inspect which rules are active before overriding them. If you already use a custom .php-cs-fixer.dist.php or phpcs.xml, review it for conflicts.
- How do I run zing/coding-standard checks in GitHub Actions or CI?
- Add the checks to GitHub Actions or another CI service by installing the dev dependency and running vendor/bin/ecs check and vendor/bin/php-cs-fixer fix --dry-run. A typical workflow uses shivammathur/setup-php with PHP 8.2 and runs on push and pull_request. Start by gating pull requests, then enforce on the main branch once the baseline is clean.
- Does zing/coding-standard work with Laravel Pint?
- Laravel Pint and zing/coding-standard both wrap PHP coding tools, so running both may duplicate or conflict with checks. If you adopt this package, disable or remove Pint from the same pipeline to avoid competing formatting rules. You can still keep Pint locally if your team deliberately separates local and CI standards.
- Will Rector rules like STRICT_BOOLEANS change my application logic?
- Rector rules such as STRICT_BOOLEANS and INSTANCEOF can change code semantics if applied blindly, so preview transformations with rector process --dry-run first. Review the diff and run your test suite before committing automated changes. Enable stricter Rector rules gradually, starting in feature branches or a single module.
- How should I adopt zing/coding-standard in an existing legacy Laravel codebase?
- For legacy code, run dry-run checks to measure violations and apply non-breaking style rules first. Then introduce Rector transformations incrementally and keep tests green at each step. A pilot module or feature branch helps the team validate rules before enforcing them repository-wide.
- Is zing/coding-standard safe for production and long-term maintenance?
- zing/coding-standard is a dev-only tool, so it is not shipped to production and adds no runtime dependencies. Its main production concern is CI stability: pin dependency versions and update PHP-CS-Fixer, ECS, and Rector deliberately. If you need a lighter or Laravel-specific option, compare it with Laravel Pint, PHP_CodeSniffer, or a direct PHP-CS-Fixer setup.