stefanzweifel/laravel-stats-phploc
Fork of sebastianbergmann/phploc used to keep wnx/laravel-stats compatible across Laravel versions by supporting multiple sebastian/version releases. Measures PHP project size and structure (LOC, complexity, dependencies). Not intended for real projects.
laravel-stats wrapper (mentioned in the README) suggests this was designed for Laravel-specific reporting, but the fork itself is not a Laravel package—it’s a compatibility layer for wnx/laravel-stats.laravel-stats package (not this fork) would handle Laravel integration (e.g., publishing metrics to a dashboard). This fork is only for compatibility.phploc.phar via Artisan::command() or a shell command.laravel-stats uses SQLite).| Risk Area | Assessment |
|---|---|
| Dependency Stability | High: Fork is not actively maintained (last release 2025-10-12). Relies on upstream phploc. |
| Laravel Version Support | Medium: Explicitly supports multiple sebastian/version versions but no Laravel version guarantees. |
| Performance Overhead | Low: CLI tool runs outside Laravel’s request cycle, but parsing output adds minor runtime cost. |
| Output Format Reliability | Medium: CLI output is human-readable but not machine-friendly. JSON/XML would reduce parsing risk. |
| Security | Low: PHAR is signed, but external execution introduces shell command risks (e.g., path injection). |
phploc?
wnx/laravel-stats compatibility. If you don’t need Laravel integration, use the official PHAR.phploc breaks?wnx/laravel-stats (or building a similar dashboard).Option A: Use Official PHAR (Recommended if no Laravel integration needed)
wget https://phar.phpunit.de/phploc.pharshell_exec() or Artisan::command():
$output = shell_exec('php phploc.phar src --log-json metrics.json');
--log-json).Option B: Laravel-Specific Integration (If using wnx/laravel-stats)
wnx/laravel-stats (not this fork) for built-in Laravel support.phploc as a scheduled task (e.g., php artisan stats:run).Option C: Custom Integration (For Advanced Use Cases)
tools/ directory.Artisan command:
php artisan make:command PhpLocMetrics
// app/Console/Commands/PhpLocMetrics.php
public function handle() {
$command = base_path('tools/phploc.phar') . ' src --log-json';
$output = shell_exec($command);
$metrics = json_decode($output, true);
// Store in DB or log
}
| Component | Compatibility Notes |
|---|---|
| PHP | Requires PHP 8.0+ (fork drops older versions). |
| Laravel | No direct Laravel version guarantees; tested with wnx/laravel-stats. |
| Dependencies | Relies on sebastian/version v4 (fixed in recent releases). |
| Output Formats | Supports CLI, JSON, XML (JSON recommended for programmatic use). |
| CI/CD | Works in Linux/macOS (PHAR is cross-platform). Windows may need adjustments. |
tools/ directory or use Phive.wnx/laravel-stats if Laravel integration is needed.app/, packages/).wnx/laravel-stats changes, this fork may break.wnx/laravel-stats).| Failure Scenario | Impact | Mitigation Strategy |
|---|---|---|
| PHAR execution fails | No metrics generated | Use try-catch for shell commands. |
| Output format changes | Parsing breaks | Test against new releases; use JSON. |
| Laravel version incompatibility | Integration fails | Pin Laravel version; test in staging. |
| High complexity thresholds | False positives in alerts | Start with warning (not block) thresholds. |
| CI/CD timeout | Scan interrupted | Run in a separate job or cache results. |
php phploc.phar src to see metrics.How can I help you explore Laravel packages today?