--type=laravel) reclassifies components (e.g., *Action → Application, ServiceProvider → Wiring) to align with Laravel’s architecture.ProjectAnalyzer and HtmlReportGenerator can be extended or replaced.--type=laravel flag adapts analysis to Laravel’s conventions (e.g., excluding Eloquent/Carbon from DIP violations). However, custom logic (e.g., Facade dependencies) may require phpquality.json overrides.phpquality:analyze), avoiding runtime overhead. Reports are generated post-deployment.nikic/php-parser (PHP 8.3+) or Symfony components. Test in a staging environment first.ProjectType to add Laravel-specific exclusions.| Risk Area | Mitigation Strategy |
|---|---|
| False Positives | Leverage phpquality.json to whitelist Laravel patterns (e.g., Facades, Jobs). |
| Performance | Exclude large directories (e.g., vendor/, storage/) via --exclude. |
| Breaking Changes | Pin baseline violations (--generate-baseline) during migration from 1.x to 2.0. |
| Report Customization | Override Twig templates or extend HtmlReportGenerator for Laravel-specific metrics. |
| CI Failures | Use --fail-on-violation only after establishing a baseline. |
phpquality.json as Laravel evolves (e.g., new Facade patterns)?# GitHub Actions
- name: Run PhpQuality
run: docker run --rm -v ${{ github.workspace }}:/project amoifr13/phpquality --source=/project/app --type=laravel --report-html=/tmp/reports
composer require amoifr/phpquality-bundle
Then register the bundle in config/bundles.php (even if unused, for dependency injection).// app/Console/Commands/PhpQualityCommand.php
class PhpQualityCommand extends Command {
protected $signature = 'phpquality:run {--source=app : Source directory}';
public function handle() {
$source = $this->option('source');
shell_exec("php bin/console phpquality:analyze --source=$source --type=laravel");
}
}
Storage facade or published to a /reports route.app/Http/Controllers) with --generate-baseline.phpquality.baseline.json.--baseline to CI checks for new violations only.phpquality.json for Laravel-specific rules (e.g., exclude App\Jobs\* from DIP).| Component | Compatibility Notes |
|---|---|
| PHP 8.3+ | Required for nikic/php-parser and Symfony 7.x. |
| Laravel 9/10 | No native integration, but --type=laravel adapts analysis. |
| Composer | Bundle installs as a dependency; no global conflicts expected. |
| Docker | Alpine-based image (~50MB) avoids bloat. |
| CI Systems | Supports GitHub Actions, GitLab CI, and Jenkins via Docker or CLI. |
phpquality.json to exclude Laravel-specific paths (e.g., storage/, bootstrap/).{
"ignore": {
"directories": ["app/Providers", "app/Exceptions"],
"violations": ["solid.dip:App\\Jobs\\*"]
}
}
php bin/console phpquality:analyze --source=app --type=laravel --generate-baseline=phpquality.baseline.json
- name: PhpQuality
run: php bin/console phpquality:analyze --source=app --type=laravel --baseline=phpquality.baseline.json --fail-on-violation
/storage/app/public/reports or a CDN.phpquality.json may become outdated as Laravel evolves (e.g., new Facade patterns).CODE_QUALITY.md file and review annually.composer.json.phpquality.json or submit patches to the project.--no-html for terminal output to debug issues.--entrypoint=bash for troubleshooting.phpquality.json examples.--exclude=app/Providers) to reduce analysis time.--json for lightweight exports.phpquality.baseline.json in the repo to standardize rules.Storage + Nginx).| Failure Scenario | Impact | Recovery Strategy |
|---|---|---|
| CI Timeout | Build failures | Split analysis into smaller batches or run in a separate job. |
| False Violation Block | PRs blocked by baselines | Temporarily disable --fail-on-violation and update baselines. |
| Docker Image Issues | Analysis fails in CI | Use --entrypoint=bash to debug or switch to CLI installation. |
How can I help you explore Laravel packages today?