consistence/coding-standard
PHP coding standard for Consistence projects: a ready-to-use PHP_CodeSniffer ruleset plus configuration to enforce consistent style, naming, and best practices across codebases. Easy to adopt in CI and local development to keep code clean and uniform.
empty()).composer require --dev consistence/coding-standard.phpcs.xml:
<config defaultStandard="Consistence">
<arg name="extensions" value="php" />
</config>
./vendor/bin/phpcs --standard=Consistence app/.- name: Run PHPCS
run: ./vendor/bin/phpcs --standard=Consistence --warning-severity=0 app/
phpcs command.phpstan/extension-installer to bundle PHPCS rules.phpcs or roave/security-advisories wrappers.ArrayDeclaration errors).| Risk | Impact | Mitigation Strategy |
|---|---|---|
| Stale Maintenance | No updates since 2020; risk of drift with PHP 8.x/9.x. | Evaluate forks (e.g., php-cs-fixer) or supplement with PSR-12 rules. |
| Rule Conflicts | Overlap with php-cs-fixer or Laravel’s pint. |
Audit rules pre-adoption; use --ignore for conflicts (e.g., Squiz.Arrays.ArrayDeclaration). |
| Performance Overhead | PHPCS can slow CI pipelines for large codebases. | Cache results (--cache) or run selectively (e.g., changed-files in CI). |
| PHP Version Gaps | Drops PHP 7.0/7.1 support; Laravel 7.x may need polyfills. | Target Laravel 8+/PHP 7.2+ projects; document version requirements. |
| False Positives | Rules like empty() ban may flag legacy code. |
Configure exceptions in phpcs.xml or phase adoption. |
| IDE Plugin Gaps | Older PHPCS version may lack IDE plugin support. | Test with PHPStorm/VSCode PHPCS plugins; update PHPCS if needed. |
php-cs-fixer) or run alongside them?empty() ban for legacy code)?CONTRIBUTING.md?php-cs-fixer)?extension-installer for static analysis.pre-commit (e.g., with husky or pre-commit.com).PHP Intelephense + PHP_CodeSniffer integration../vendor/bin/phpcs --standard=Consistence --report=full app/ > phpcs-report.txt
php-cs-fixer to auto-fix compatible rules (e.g., spacing, indentation).phpcs.xml:
<rule ref="Consistence.Arrays.ArrayDeclaration" severity="0" />
| Component | Compatibility | Notes |
|---|---|---|
| Laravel Versions | 8.x+ (PHP 7.2+); 7.x with polyfills. | Avoid PHP 7.0/7.1 due to package drops support. |
| PHPCS Versions | Tested with v3.5; may work with v3.7. | Update PHPCS if IDE plugin issues arise. |
| PHP-CS-Fixer | Rules overlap (e.g., spacing); configure exclusions. | Use php-cs-fixer for auto-fixes, PHPCS for linting. |
| Legacy Code | Rules like empty() ban may require exceptions. |
Document exceptions in phpcs.xml or CONTRIBUTING.md. |
| Monorepos | Works per-project; configure phpcs.xml per module. |
Use --path flag to target specific directories. |
time ./vendor/bin/phpcs app/).composer.json dev dependencies.phpcs.xml in project root.CONTRIBUTING.md with rules.phpcs --cache).phpcs --parallel).How can I help you explore Laravel packages today?