composer require --dev arty/php-coding-standard
phpcs.xml in your project root:
<?xml version="1.0"?>
<ruleset name="Arty Coding Standard">
<rule ref="./vendor/arty/php-coding-standard/lib/phpcs/phpcs.xml" />
</ruleset>
phpstan.neon:
includes:
- vendor/arty/php-coding-standard/lib/phpstan/phpstan.neon
./vendor/bin/phpcs src
--level as needed):
./vendor/bin/phpstan analyse --level=max src
Pre-commit hook: Integrate PHPCS/PHPStan into your Git workflow to catch style/bug issues before merging:
# Example in .git/hooks/pre-commit
#!/bin/sh
./vendor/bin/phpcs src || exit 1
./vendor/bin/phpstan analyse --level=5 src || exit 1
CI/CD Pipeline
# .github/workflows/lint.yml
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: composer install
- run: ./vendor/bin/phpcs src
- run: ./vendor/bin/phpstan analyse --level=max src
Laravel-Specific Rules
App\Services\ namespace):
<!-- phpcs.xml -->
<rule ref="vendor/arty/php-coding-standard/lib/phpcs/phpcs.xml">
<exclude-pattern>*/Tests/*</exclude-pattern>
<exclude-pattern>*/Resources/*</exclude-pattern>
</rule>
PHPStan Level Tuning
--level=5 for development, --level=max for production:
# In package.json scripts
"lint:strict": "phpstan analyse --level=max src"
PHPAt for Architecture
# phpstan.neon
services:
- { class: ArtyCodingStandard\PHPAt\CleanArchitectureTest, tags: ["phpat.test"] }
./vendor/bin/phpstan analyse --extension=phpat src
# Run PHPCS on changed files (via Git)
git diff --name-only HEAD~1 | xargs ./vendor/bin/phpcs
--fix flag for PHPCS (where supported):
./vendor/bin/phpcs --fix src
PHPStan Performance
--level=max can be slow for large Laravel apps. Start with --level=5 and incrementally raise.vendor/, node_modules/):
excludeFiles:
- '*/vendor/*'
- '*/node_modules/*'
PHPCS False Positives
$fillable) may trigger rules. Exclude or override:
<!-- phpcs.xml -->
<rule ref="vendor/arty/php-coding-standard/lib/phpcs/phpcs.xml">
<exclude name="Generic.Files.LineEndings" />
</rule>
PHPAt Overhead
./vendor/bin/phpstan analyse --extension=phpat --no-progress src
PHPCS Errors
--report=full for detailed output:
./vendor/bin/phpcs --report=full src
phpcs.xml paths if rules fail to load.PHPStan Errors
--generate-baseline:
./vendor/bin/phpstan analyse --generate-baseline src
PHPAt Failures
phpstan.neon:
services:
- { class: ArtyCodingStandard\PHPAt\CleanArchitectureTest, tags: ["phpat.test"], disabled: true }
Custom Rules
phpcs.xml:
<rule ref="vendor/arty/php-coding-standard/lib/phpcs/phpcs.xml">
<arg name="tab-width" value="4" />
</rule>
phpstan.neon:
extends:
- phpstan/extension-installer
Laravel-Specific Extensions
phpstan/laravel extension alongside:
includes:
- vendor/arty/php-coding-standard/lib/phpstan/phpstan.neon
- vendor/phpstan/extension-installer/laravel.neon
Git Hooks
roave/security-advisories for dependency checks:
composer require --dev roave/security-advisories
composer.json:
"scripts": {
"lint": "phpcs src && phpstan analyse --level=5 src"
}
How can I help you explore Laravel packages today?