php-collective/code-sniffer
PHP_CodeSniffer ruleset from PhpCollective: PSR-2 compliant with many extra sniffs/fixers (incl. PSR-12). Install via composer, add the provided ruleset to phpcs.xml, and run phpcs/phpcbf (or composer scripts) to check and auto-fix coding style.
PhpCollectiveStrict), allowing customization for stricter or project-specific rules.composer require-dev, phpcs.xml configuration). No Laravel-specific dependencies or hooks needed.cs-check, cs-fix) align with Laravel’s CI/CD workflows (e.g., GitHub Actions, Git hooks).0.6.0 enforces stricter use statements (e.g., no partial namespaces like Mockery\MockInterface). Requires explicit opt-in via phpcs.xml if backward compatibility is needed.DocBlockVarSniff) may flag class aliases incorrectly. Mitigated by project-specific overrides in phpcs.xml.--parallel=16) may require CI adjustments for large codebases.PhpCollective (PSR-2 + extras) or PhpCollectiveStrict (stricter subset)?ReferenceUsedNamesOnly)?--parallel=N and benchmark.phpcs.xml if new sniffs are added?PHPStan level 8 + php-collective/code-sniffer).phpcbf).composer cs-check.composer.json (require-dev).phpcs.xml with PhpCollective standard.composer cs-check in a staging environment to identify violations.app/Console).app/Http, app/Models, etc.PhpCollectiveStrict after stabilizing on PhpCollective.laravel-shift/php-console-color).phpcs.xml (e.g., disable DocBlockTagOrder for legacy code).pre-commit) or CI (e.g., fail builds on violations).phpcbf in CI to auto-fix non-breaking issues (e.g., whitespace).README.md as a coding standard requirement for new contributors.phpcs.xml in the repo to avoid per-developer overrides.php-collective/code-sniffer for new sniffs/fixes (e.g., PHP 8.5 support in 0.5.2).^4.0.0 in 0.4.0).@param tags") in CONTRIBUTING.md.phpcs output to identify flaky tests or environment-specific issues.--parallel=N in CI (e.g., N=8 for 8-core machines) to reduce runtime.vendor/ and large files (e.g., node_modules) via phpcs.xml.--cache) for repeated scans.| Scenario | Impact | Mitigation |
|---|---|---|
| CI timeout on large PRs | Blocked merges | Increase CI timeouts or use parallel scans. |
| False positives in prod code | Developer frustration | Whitelist files/rules in phpcs.xml. |
| Sniff breaking changes | Build failures | Test new versions in a staging branch. |
| IDE performance lag | Slow feedback loops | Disable file watchers; use CLI only. |
phpcs.xml, run initial scans.phpcs output in PRs; adjust rules as needed.Key Metric: Reduce "style nitpicks" in code reviews by 80% within 3 months.
How can I help you explore Laravel packages today?