Installation:
composer require ninjify/qa
Add to composer.json scripts:
"scripts": {
"qa": [
"linter src app tests",
"codesniffer src app tests"
]
}
First Run:
composer qa
php-parallel-lint) and code sniffing (phpcs) on src/, app/, and tests/ by default.Fix Issues Automatically:
vendor/bin/codefixer src app tests
php-cs-fixer to auto-correct PSR-12 violations.ruleset.xml in your project root (or use the package’s strict default)..qa.php (if created) or pass custom paths:
composer qa -- --exclude="database/"
.github/workflows/laravel.yml:
- run: composer qa
Pre-commit Hook:
# Add to .git/hooks/pre-commit
#!/bin/sh
composer qa || exit 1
Project-Wide QA:
composer qa
src/, app/, tests/).Targeted Checks:
composer qa app/Http
Fix-and-Commit Workflow:
composer qa && vendor/bin/codefixer && git add -u && git commit -m "Fix QA issues"
Custom Rulesets:
ruleset.xml in your project root to override defaults:
<rule ref="PSR12">
<exclude name="PSR12.Classes.ClassDeclaration.MissingTraitUses"/>
</rule>
CI/CD Integration:
# GitHub Actions example
jobs:
qa:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: composer install
- run: composer qa
Developer Workflow:
composer qa before pushing to catch issues early.codefixer to resolve warnings interactively.Pull Request Workflow:
- name: Run QA Checks
run: composer qa
Release Workflow:
phpstan and pest in CI:
"scripts": {
"test": "pest",
"qa": ["linter", "codesniffer"],
"ci": ["test", "qa"]
}
Laravel-Specific:
vendor/ and bootstrap/cache/ from checks:
composer qa -- --exclude="vendor/ bootstrap/cache/"
resources/ if using Blade templates:
composer qa -- --include="resources/views/"
Team Onboarding:
composer qa command in your CONTRIBUTING.md.codefixer in CI to auto-fix common issues for new contributors.Performance:
composer qa -- --parallel
False Positives:
php-parallel-lint may flag legacy PHP files (e.g., php4).composer qa -- --exclude="*/legacy/"
Ruleset Conflicts:
ruleset.xml may override Laravel’s PSR-12 defaults.vendor/bin/codesniffer --standard=PSR12
CI Failures:
codefixer modifies files, causing git diff noise.codefixer locally and commit fixes separately.PHP Version Mismatch:
composer require --dev php-parallel-lint/php-parallel-lint:^1.3
Verbose Output:
composer qa -- --verbose
Dry Run:
vendor/bin/codefixer --dry-run
Custom Exit Codes:
1 on failures. Use in CI:
- run: composer qa || exit 1
Default Folders:
.qa.php:
return [
'folders' => ['src', 'app', 'tests', 'routes'],
'exclude' => ['*/migrations/*', '*/temp/*'],
];
Ruleset Path:
vendor/bin/codesniffer --standard=/path/to/ruleset.xml
EditorConfig:
.editorconfig. Ensure consistency:
[*.php]
indent_style = space
indent_size = 4
Custom Sniffs:
ruleset.xml:
<rule ref="SlevomatCodingStandard"/>
<rule ref="Contributte\CodingStandard\Sniffs"/>
Pre/Post-QA Hooks:
composer.json scripts:
"scripts": {
"qa": [
"@pre-qa",
"linter",
"codesniffer",
"@post-qa"
]
}
Artisan Command:
// app/Console/Commands/QaCheck.php
public function handle() {
$this->call('vendor:publish', ['--provider' => 'Ninjify\Qa\QaServiceProvider']);
Artisan::call('qa');
}
Auto-Fix in CI:
codefixer in a separate CI job to auto-correct:
- name: Auto-fix QA issues
if: github.event_name == 'pull_request'
run: vendor/bin/codefixer
Exclude Tests:
# CI
composer qa -- --exclude="tests/"
# Local
composer qa
Monitor Trends:
composer qa -- --format=json > qa-results.json
How can I help you explore Laravel packages today?