danielbaylis/laravel-stats
Laravel package for collecting, storing, and querying application statistics in Laravel. Track events and counters, aggregate metrics over time, and retrieve reports via an easy API to monitor usage and performance in your app.
danielbaylis/laravel-stats package provides code statistics (e.g., lines of code, complexity metrics) for Laravel projects, which aligns with developer productivity, maintainability tracking, and technical debt assessment. It is particularly useful for:
php artisan stats:...), avoiding runtime overhead.Artisan commands and service container (v5.5+). Minimal boilerplate required.config/stats.php).| Risk Area | Assessment | Mitigation |
|---|---|---|
| Performance | CLI scans may slow for large repos (>10k files). | Schedule runs during off-peak hours; exclude vendor//node_modules/ via config. |
| Accuracy | Metrics (e.g., cyclomatic complexity) may not match IDE tools (e.g., PhpStorm). | Validate against known benchmarks; document limitations in reports. |
| Database Overhead | If storing metrics in DB, could bloat storage for frequent runs. | Use a separate DB table with TTL; aggregate historical data. |
| Customization | Limited out-of-the-box metrics (e.g., no test coverage integration). | Extend via StatsServiceProvider or fork for bespoke collectors. |
| Deprecation | Low-maintenance package (no recent commits). | Monitor GitHub issues; fork if abandoned. |
Use Case Clarity:
Data Storage:
Extensibility Needs:
Scalability:
CI/CD Integration:
Pilot Phase:
composer require danielbaylis/laravel-stats
php artisan stats:collect
php artisan stats:report
cloc) for accuracy.Configuration:
config/stats.php to:
tests/, storage/).complexity if irrelevant).'directories' => [
app_path(),
resource_path('views'),
],
'collectors' => [
\DanielBaylis\Stats\Collectors\LinesOfCode::class,
// \DanielBaylis\Stats\Collectors\Complexity::class, // Disable if needed
],
Data Pipeline:
php artisan stats:report --format=json for programmatic access.code_stats):
// In a custom Artisan command:
$stats = Stats::collect();
DB::table('code_stats')->insert([
'metric' => 'loc',
'value' => $stats->linesOfCode,
'timestamp' => now(),
]);
Automation:
$schedule->command('stats:collect')->weekly();
- name: Generate Code Stats
run: php artisan stats:collect
- name: Upload Report
uses: actions/upload-artifact@v3
with:
name: code-stats
path: storage/app/stats.json
Phase 1: Validation (1–2 weeks)
Phase 2: Integration (1–3 weeks)
Phase 3: Automation (1 week)
Phase 4: Extension (Ongoing)
phpunit).config/stats.php changes in README or wiki.code_stats_v1).app/ and vendor/ (if needed).--exclude flags or run during off-hours.cloc or phpmd.php artisan stats:collect --verbose
How can I help you explore Laravel packages today?