cakephp/cakephp-codesniffer
CakePHP coding standard for PHP_CodeSniffer. Fully PSR-12 compliant plus additional CakePHP-specific sniffs and fixers. Install via Composer and run phpcs with --standard=CakePHP (or use a phpcs.xml) to check and auto-fix your code.
camelCase controllers, Table/Entity patterns) remain fundamentally misaligned with Laravel’s PSR-12/Pint standards, creating persistent friction.installed_paths from config files forces Laravel projects to update .phpcs.xml, introducing high migration friction if not already using PSR-12-compatible configs..phpcs.xml updates: Teams must remove installed_paths and pin PHP_CodeSniffer 4.0+, risking broken pipelines if not preemptively tested.Naming sniffs (e.g., camelCase controllers) will flag Laravel’s PascalCase Facades, requiring whitelisting or custom exceptions.| Risk Area | Severity | Mitigation Strategy |
|---|---|---|
| Config Breaking Change | Critical | Pre-migrate: Update .phpcs.xml to remove installed_paths; test locally before CI. |
| Rule Conflicts | Critical | Override rules via custom .phpcs.xml snippets or Laravel-specific exceptions. Example: |
| ```xml | ||
| ``` | ||
| Toolchain Bloat | High | Modular adoption: Use CakePHP Sniffer only for legacy modules; keep Pint for PSR-12. |
| PHP_CodeSniffer 4.0 Dependency | Medium | Ensure CI/CD uses PHP_CodeSniffer 4.0+ (most modern setups already comply). |
| False Positives | High | Whitelist Laravel paths in .phpcs.xml: |
| ```xml | ||
| ``` | ||
| 5.next Branch Stability | Medium | Pin to 5.3.0 until 5.next stabilizes; monitor CakePHP’s deprecation timeline. |
installed_paths affect Laravel’s existing .phpcs.xml?CakePHP.Naming sniffs)?5.3.0?camelCase controllers vs. Laravel’s PascalCase Facades.Table/Entity vs. Laravel’s Eloquent.Route::prefix() vs. Laravel’s Route::group().SquizLabs/PHP_CodeSniffer directly)..phpcs.xml: Remove installed_paths and update to PHP_CodeSniffer 4.0.phpcs against a subset of files to catch breaking changes.cakephp/cakephp-codesniffer to 5.3.0 to avoid 5.next instability.cakephp/cakephp-codesniffer:5.3.0 and run only on non-critical paths (e.g., tests, utilities)..phpcs.xml:
<config name="installed_paths" value="vendor/cakephp/cakephp-codesniffer"/>
<arg name="exclude" value="app/Providers,routes,tests/CakePHP"/>
<rule ref="CakePHP.Naming.Conventions.ControllerName">
<properties>
<property name="case" type="string" value="pascal"/>
</properties>
</rule>
.phpcs.xml exclusions iteratively.Table/Entity rules will conflict with Laravel’s Eloquent. Mitigation: Exclude app/Models/ in .phpcs.xml.Service naming vs. Laravel’s Facade/ServiceProvider remains a known conflict. Solution:
app/Providers/ in .phpcs.xml.{{ $var }} vs. Laravel’s {{ $var }} (same syntax, but CakePHP may enforce stricter rules). **MitigationHow can I help you explore Laravel packages today?