sandfox.dev/code-standard
Shared coding standards and tooling used across sandfox.dev PHP/Laravel packages. Provides a consistent rule set for formatting and static analysis to keep code style uniform, reduce review friction, and maintain quality across projects.
Route::prefix() usage).composer cs-check) without requiring new infrastructure.phpstan.neon to exclude files already covered by CodeSniffer..blade.php files (e.g., @foreach syntax).handle() method signatures or signature() usage.register()/boot() method ordering..php) will be scanned for consistency.camelCase as error, but custom rules might enforce snake_case).phpcs with both standards and merge rules in .phpcs.xml:
<rule ref="PSR12">
<exclude name="Classes.Methods.CamelCapsMethodName"/>
</rule>
--parallel flag or cache results (e.g., GitHub Actions artifact caching).Route::get() use snake_case or camelCase route names?str()") or generic (e.g., "no trailing whitespace")?- name: PHP_CodeSniffer
run: composer cs-check
composer require --dev sandfox.dev/code-standard and test on a non-critical branch:
./vendor/bin/phpcs --standard=SandfoxDev/CodeStandard --report=full src/
app/Http/Controllers/):
<!-- .phpcs.xml -->
<arg name="directory" value="app/Http/Controllers" />
--ignore for known legacy violations:
./vendor/bin/phpcs --standard=SandfoxDev/CodeStandard --ignore=app/OldModule
.phpcs.xml to include the standard globally:
<config name="standard" value="SandfoxDev/CodeStandard"/>
squizlabs/php_codesniffer:^6.0..phpcs.xml to exclude or adjust severity for specific rules:
<rule ref="SandfoxDev/CodeStandard.Methods.CamelCaps">
<severity>warning</severity>
</rule>
<file>app/Providers/AppServiceProvider.php</file>
<exclude name="SandfoxDev/CodeStandard.Providers.RegisterMethodFirst"/>
.husky/pre-commit:
#!/bin/sh
./vendor/bin/phpcs --standard=SandfoxDev/CodeStandard --warning-severity=3
- name: PHP_CodeSniffer (Warnings)
if: github.event_name == 'pull_request'
run: composer cs-check --warning-severity=3
AppServiceProvider.php for register() order").sandfox-dev/code-standard) if the original package stagnates.composer.json to avoid breaking changes:
"sandfox.dev/code-standard": "1.0.0"
composer.json:
"require-dev": {
"squizlabs/php_codesniffer": "^6.0",
"friendsofphp/php-cs-fixer": "^3.0"
}
str() instead of strlen()").| Violation | Fix |
|---|---|
Methods.CamelCapsMethodName |
getUserData() → getUserData() (or get_user_data() if enforced) |
Controllers.RoutePrefix |
Route::prefix('admin') → Route::prefix('admin/') |
"intele
How can I help you explore Laravel packages today?