onramplab/onr-phpcs-laravel
Opinionated PHP_CodeSniffer ruleset for Laravel projects. Provides a ready-to-use PHPCS configuration with Laravel-focused coding standards to help keep code style consistent across your app and team.
laravel standard).php-cs-fixer or robo.phar).Sniff classes, allowing TPMs to enforce team-specific standards (e.g., docblock formats, naming conventions).composer require --dev onramplab/onr-phpcs-laravel
phpcs.xml or phpcs.xml.dist (Laravel’s default PHPCS config location).squizlabs/php_codesniffer, dealerdirect/phpcodesniffer-composer-normalize).| Risk Area | Severity | Mitigation |
|---|---|---|
| Rule Conflicts | Medium | Validate against existing phpcs.xml; use --strict flag to catch violations. |
| Performance Overhead | Low | PHPCS runs on demand (CI/CD or local); cache results with tools like phpcs --cache. |
| Maintenance Burden | Low | Unlicense = minimal legal risk; updates via Composer. |
| False Positives | Medium | Customize rules via phpcs.xml or extend the package’s Sniff classes. |
| Dependency Bloat | Low | Only adds PHPCS (~1MB); no runtime impact. |
pint, phpstan)?pre-commit hooks)?phpcs.xml)?php-parallel-lint for large codebases).robo.phar tasks.Dockerfile for consistent linting across environments.phpcs.xml for conflicts.vendor/bin/phpcs --standard=onramplab/onr-phpcs-laravel app/
composer.json dev dependencies.phpcs.xml to include the new standard.pint for auto-formatting).^3.7) in composer.json.<!-- phpcs.xml -->
<config name="installed_paths" value="vendor/onramplab/onr-phpcs-laravel"/>
<rule ref="onramplab/onr-phpcs-laravel"/>
composer.json:
"require-dev": {
"onramplab/onr-phpcs-laravel": "^1.0"
}
phpcs.xml:
<config name="standard" value="onramplab/onr-phpcs-laravel"/>
- name: Run PHPCS
run: vendor/bin/phpcs --standard=onramplab/onr-phpcs-laravel --error-severity=5
husky + php-cs-fixer).composer update.phpcs.xml (no code changes).vendor/bin/phpcs --config-show
vendor/bin/phpcs --verbose app/
@ignore annotations).--parallel or cache results:
vendor/bin/phpcs --cache=/tmp/phpcs-cache
phpcs.xml in a monorepo or shared config repo.phpcs.xml files (e.g., phpcs-app.xml, phpcs-tests.xml).<arg> to toggle rules:
<arg name="extensions" value="php,blade" />
| Failure Scenario | Impact | Mitigation |
|---|---|---|
| CI Build Fails on Violations | Blocked merges | Start with --warning severity, then escalate to --error. |
| False Positives in Production | Dev frustration | Maintain a whitelist of exceptions in phpcs.xml. |
How can I help you explore Laravel packages today?