shipmonk/coding-standard
ShipMonk’s PHP coding standard built on PHP_CodeSniffer and Slevomat rules. Install as a dev dependency, add a phpcs.xml.dist referencing ShipMonkCodingStandard, then run phpcs to check code and phpcbf to auto-fix issues.
@template* annotations, trait ordering) that align with Laravel’s PHP 8.5+ ecosystem. However, it lacks native Laravel-specific rules (e.g., Blade syntax, Facade patterns, Eloquent conventions), making it incompatible with Laravel’s idiomatic patterns without custom overrides.slevomat/coding-standard@^8.25.0) and drops backward compatibility (e.g., removed RequireSelfReference). Projects using older PHP versions or tools (e.g., PHPStan <8.0) may encounter integration issues or rule conflicts.phpcbf could break Laravel-specific patterns (e.g., reordering use statements for Facades, altering exception handling in middleware).ReturnTypeDeclaration may conflict with PHPStan’s expectations or Rector’s refactoring rules.composer require --dev shipmonk/coding-standard) but no Laravel-specific installation hooks (e.g., service provider, package discovery).phpcs.xml.dist setup, which is straightforward but not self-documenting for new teams. The provided template assumes ShipMonk’s directory structure (src/, tests/), which may not match all Laravel projects (e.g., app/, database/).app/Exceptions, app/Http/Middleware) from PHPCS.CatchExceptionsOrder) in phpcs.xml.phpcbf --dry-run to test auto-fixes before applying them.ThrowsAnnotationsOrder or TraitUseOrder may flag Laravel-specific patterns as violations (e.g., middleware exception handling, Facade trait usage).phpcbf) Danger: Could alter Laravel’s implicit behavior (e.g., reordering use statements for Facades, modifying exception hierarchies in middleware).slevomat/coding-standard (a large dependency) even if only a subset of rules is needed. For lightweight projects, this may be overkill.var/phpcs.cache) helps, but large Laravel monorepos (e.g., with many Facades or middleware) could experience slow analysis due to the package’s strict rule set.CatchExceptionsOrder) without forking?phpcbf been tested on a Laravel codebase to ensure it doesn’t break critical functionality?@template* annotations)?RequireSelfReference)?var/phpcs.cache) perform on a large Laravel codebase (e.g., 10K+ lines)?vendor/, node_modules/) to speed up analysis?use Illuminate\Support\Facades\Log;).ReturnTypeDeclaration vs. PHPStan’s expectations).slevomat/coding-standard@^7.0).vendor/bin/phpcs --sniffs=ShipMonkCodingStandard --report=full on a sample Laravel project to identify conflicts (e.g., Facade ordering, exception handling).phpcbf --dry-run to simulate auto-fixes and check for breaking changes.app/Http/Middleware, app/Exceptions).phpcs.xml.dist to:
CatchExceptionsOrder).<exclude-pattern>app/Http/Middleware</exclude-pattern>).<rule> overrides.- name: PHPCS
run: vendor/bin/phpcs --standard=ShipMonkCodingStandard --warning-severity=3
--ignore=* initially, then tighten rules).| Component | Compatibility | Workaround |
|---|---|---|
| Laravel Facades | ❌ Conflicts with UseStatementOrder, TraitUseOrder |
Exclude app/ or override sniffs in phpcs.xml. |
| Middleware/Exceptions | ❌ CatchExceptionsOrder may break exception hierarchies |
Disable sniff or exclude app/Http/Middleware. |
| Blade Templates | ❌ No support for Blade syntax | Use `slevomat/c |
How can I help you explore Laravel packages today?