respect/coding-standard
Respect Coding Standard provides a set of PHP_CodeSniffer rules used across Respect components, helping enforce consistent code style and best practices in PHP projects.
respect/coding-standard package enforces Respect’s PHP coding conventions via PHP_CodeSniffer, aligning with developer consistency and maintainability goals in Laravel projects. It is not a core architectural component but enhances code quality and team productivity, which is critical for TPMs managing Laravel-based products.respect/validation or respect/http). The opportunity score (32.88) suggests significant value for teams prioritizing strict coding standards.laravel-shift/php-pact) or PSR-12 for hybrid standards.squizlabs/php_codesniffer:^4.0), which is not bundled with Laravel by default. Adds ~5MB to tooling footprint.doctrine/coding-standard:^14.0) is a dependency, which may introduce conflicting rules if not managed.laravel-pint or laravel-shift, this package doesn’t account for Laravel’s artisan commands, facade patterns, or blade templates.| Risk Area | Severity | Mitigation Strategy |
|---|---|---|
| Rule Conflicts | Medium | Audit existing codebase against Respect rules before adoption. Use --ignore flags or customize .phpcs.xml. |
| Tooling Overhead | Low | Containerize PHP_CodeSniffer in CI (e.g., Docker) to avoid local setup friction. |
| Maintenance Burden | Low | Rules are static; updates require minimal effort unless Respect changes conventions. |
| False Positives | Medium | Test against a subset of the codebase first; adjust rules via .phpcs.xml. |
| Dependency Bloat | Low | Only adds ~5MB; negligible for most projects. |
| Blade Template Support | High | Exclude Blade files from linting or create custom rules for Blade-specific standards. |
respect/validation, respect/http)? If not, is there a long-term plan to adopt them?SnakeCase for methods vs. Laravel’s camelCase)?dealerdirect/phpcodesniffer-composer-installer, laravel-shift/php-pact) with lower friction or better Laravel integration?phpcs, parallel-lint, or custom scripts).handle() vs. execute()).app() helper usage.ValidClassName may conflict with Laravel’s AppServiceProvider naming.<ruleset>
<rule ref="PSR12"/>
<rule ref="Respect">
<exclude name="Respect.NamingConventions.ValidClassName"/>
</rule>
</ruleset>
composer require --dev respect/coding-standard
vendor/bin/phpcs --standard=Respect --ignore=*,*.blade.php src/ tests/
.phpcs.xml to override conflicting rules:
<ruleset>
<rule ref="Respect">
<exclude name="Respect.NamingConventions.SnakeCaseMethods"/>
<exclude-pattern>*/AppServiceProvider.php</exclude-pattern>
<exclude-pattern>*/Console/*Command.php</exclude-pattern>
</rule>
</ruleset>
- name: Run Respect Coding Standard (Warning)
run: vendor/bin/phpcs --standard=Respect --warning-severity=0 src/ || true
husky or roave/infection):
# .husky/pre-commit
#!/bin/sh
vendor/bin/phpcs --standard=Respect --report=summary src/ || exit 1
| Component | Compatibility | Notes |
|---|---|---|
| Laravel 10/11 | High | PHP 8.1+ compliant. |
| PHP_CodeSniffer 4.x | High | Required dependency. |
| PSR-12 | Medium | Rule conflicts possible (e.g., naming). |
| Laravel Pint | Medium | May need rule exclusions. |
| Blade Templates | Low | Not linted by default; requires exclusion or custom rules. |
| Artisan Commands | Medium | May flag Laravel-specific conventions. |
| Custom Laravel Rules |
How can I help you explore Laravel packages today?