chaplean/coding-standard
Chaplean Coding Standard provides a ready-to-use PHP_CodeSniffer ruleset for consistent PHP and Laravel code style. Drop-in configuration to enforce formatting, naming conventions, and best practices across your project and CI.
chaplean/coding-standard package is a PHP_CodeSniffer ruleset designed to enforce consistent coding standards in PHP/Laravel projects. It does not alter Laravel’s core architecture but integrates as a static analysis layer, making it ideal for:
composer require --dev chaplean/coding-standard).phpcs.xml or CLI flags (e.g., --standard=chaplean).ruleset.xml (e.g., exclude Blade files).use App\Facades\Cache; as non-compliant if Chaplean enforces fully qualified paths.--cache).__invoke magic methods).snake_case in method names (common in Laravel) or enforce camelCase?ruleset.xml structure documented?RouteServiceProvider)?Route::get() as non-compliant if Chaplean enforces PSR-12’s Http\Router?PSR12 + custom rules)?roave/security-advisories) alongside PHPCS.squizlabs/php_codesniffer (PSR-12) + custom rules.dealerdirect/phpcodesniffer-composer-installer for project-specific standards.resources/views/), migrations, or config files.app/Providers/RouteServiceProvider.php) to identify conflicts.phpcs --standard=chaplean on a subset of files (e.g., app/Http/Controllers/).phpcs --standard=PSR12 to identify rule conflicts.composer.json under require-dev:
"require-dev": {
"chaplean/coding-standard": "^1.0"
}
--ignore=* initially, then whitelist files via .phpcs.xml:
<file>app/Http/Controllers/</file>
<exclude-pattern>*/tests/*</exclude-pattern>
.github/workflows/ci.yml:
- name: Run Chaplean Coding Standards
run: |
composer require --dev chaplean/coding-standard
vendor/bin/phpcs --standard=chaplean --warning-severity=3 src/
--error-severity as needed).--ignore=resources/views/ or .phpcs.xml.use App\Facades\Cache).database/migrations/).phpcs version conflicts with other tools (e.g., laravel-pint).composer why-not chaplean/coding-standard to detect conflicts.phpcs globally or via Composer:
composer global require squizlabs/php_codesniffer
.phpcs.xml to prioritize Chaplean:
<config name="installedPackages" value="chaplean/coding-standard"/>
<rule ref="Chaplean">
<exclude name="Generic.Files.LineEndings" />
<arg name="extensions" value="php" />
</rule>
vendor/bin/phpcs --standard=chaplean app/Http/Controllers/UserController.php
- name: PHPCS (Chaplean)
uses: actions/cache@v3
with:
path: ~/.phpcs.cache
key: phpcs-cache
- run: vendor/bin/phpcs --standard=chaplean --cache ~/.phpcs.cache src/
CONTRIBUTING.md.Settings > Editor > Code Style > PHP > PHP Code Sniffer
Standard: Chaplean
How can I help you explore Laravel packages today?