bmitch/churn-php
churn-php helps you spot PHP files that are likely refactoring candidates by analyzing Git commit churn and cyclomatic complexity, then ranking files with a combined score and presenting the results in an easy-to-read table.
churn-php is a static analysis tool designed to identify PHP files with high cyclomatic complexity and commit churn, making it a complementary tool to Laravel’s existing ecosystem (e.g., Pest, PHPStan, Psalm).churn run) or Composer dev dependency, avoiding direct Laravel integration. This aligns with Laravel’s modular philosophy.BeforeAnalysisHook, AfterFileAnalysisHook, and AfterAnalysisHook, which could be leveraged for Laravel-specific extensions (e.g., ignoring vendor files, focusing on app/ directory).parallelJobs config), reducing runtime for large codebases.cachePath) can speed up repeated runs in CI/CD.parallelJobs > 1 on shared CI runners.churn.yml tuning (e.g., filesToIgnore, directoriesToScan) to avoid noise (e.g., vendor/, node_modules/).app/, or include packages//modules/ (if using modular Laravel)?.blade.php)? Currently excluded by default.maxScoreThreshold)?markdown output + CI annotations)?churn.yml configuration? DevOps, backend team, or shared?composer require --dev bmitch/churn-php
app/ directory:
vendor/bin/churn run app/ --format markdown > churn-report.md
composer.json scripts:
"scripts": {
"churn": "churn run app/ --format json --maxScoreThreshold 0.8"
}
- name: Run Churn Analysis
run: composer churn
maxScoreThreshold exceeded.churn.yml with:
directoriesToScan:
- app/
- packages/
filesToIgnore:
- app/Providers/*
- app/Exceptions/*
minScoreToShow: 0.3
maxScoreThreshold: 0.7
filesToIgnore:
filesToIgnore:
- app/Providers/AppServiceProvider.php
- app/Http/Kernel.php
- bootstrap/*
app/Http/Controllers/, app/Services/, and app/Models/ in directoriesToScan.--configuration to override paths per repo.cachePath) to avoid redundant Git history scans.churn.yml may become outdated if directory structures change.churn-php is actively maintained (last release: 2026), but PHPStan/PDepend (underlying tools) may require updates.composer.json or use --dev updates cautiously.CODE_HEALTH.md in the repo with churn examples and thresholds.minScoreToShow or filesToIgnore.parallelJobs or use cachePath.--depth 0 in CI).cachePath to avoid re-scanning Git history.parallelJobs: 10 works for most Laravel apps; increase to 20+ for monorepos.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Git history unavailable | No churn data | Use --vcs none (but lose commit metrics). |
High maxScoreThreshold |
Builds fail unnecessarily | Start with null (no failure), then tune. |
| Hook errors | Analysis halts | Log hook errors to file; use try-catch. |
| CI timeouts | Flaky pipelines | Cache results; run in parallel with other jobs. |
False positives in app/ |
Over-refactoring | Exclude known-safe files in churn.yml. |
How can I help you explore Laravel packages today?