Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Phploc Laravel Package

cmgmyr/phploc

Laravel-friendly wrapper around phpLOC for measuring PHP project size and structure. Generate lines-of-code, classes, methods, complexity-style stats from the command line or within builds to quickly gauge codebase scope and trends.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Strengths:
    • Lightweight, CLI-driven tool designed for PHP/Laravel codebase metrics (LOC, complexity, structure), aligning with Laravel’s Artisan command ecosystem.
    • Outputs structured, actionable metrics (e.g., class/method lengths, cyclomatic complexity) that integrate well with technical debt tracking and CI/CD gates.
    • Zero-configuration for Laravel projects (auto-detects app/, routes/, database/ directories by default).
    • Low overhead: No database or external dependencies; runs as a standalone Composer package.
  • Weaknesses:
    • No native Laravel service provider or facade integration—must be invoked via CLI (php artisan phploc).
    • Limited Laravel-specific features (e.g., no Blade template analysis, Eloquent model focus).
    • Dependency on sebastianbergmann/phploc (now forked as cmgmyr/phploc), which may introduce backward compatibility risks if the fork diverges.
    • No API mode: Output is CLI-only; requires parsing text for programmatic use (e.g., storing metrics in a database).

Integration Feasibility

  • Pros:
    • Composer-installable: Simple require --dev cmgmyr/phploc integration.
    • Artisan-compatible: Works out-of-the-box with Laravel’s CLI tooling.
    • No PHP version conflicts: Supports PHP 7.4–8.0 (aligns with Laravel 8+).
  • Cons:
    • Repository unknown status: Raises trust/availability concerns (e.g., is it a legitimate fork?).
    • No Laravel-specific documentation: Assumes familiarity with sebastianbergmann/phploc’s original CLI.
    • Potential path issues: Laravel’s vendor/ directory might be excluded by default (requires --exclude flags).
    • No official Laravel package: Lacks Packagist badges, Laravel-specific tests, or community plugins.

Technical Risk

  • High:
    • Forked package risks: cmgmyr/phploc is a recent fork (2024) of sebastianbergmann/phploc, which may introduce untested changes or dependency drift.
    • Low adoption: Only 26 stars and no dependents suggest limited validation.
    • Last release date anomaly: "2026-05-22" appears future-dated (likely a data error or spoofed).
    • No CI/CD integration examples: Risk of false positives/negatives in automated pipelines.
    • No Laravel-specific testing: May fail on custom Laravel structures (e.g., unusual namespace paths).
  • Mitigations:
    • Vendor the package: Lock version in composer.json to avoid updates ("cmgmyr/phploc": "8.0.7").
    • Test on a staging copy: Validate output against known Laravel projects (e.g., Laravel Framework itself).
    • Fallback to original: Use sebastianbergmann/phploc (last updated 2023) if cmgmyr/ is unreliable.

Key Questions

  1. Repository legitimacy:
    • Is cmgmyr/phploc a trusted fork, or is it abandoned/unmaintained?
    • Can the package be installed via Packagist (composer show cmgmyr/phploc)?
  2. Laravel compatibility:
    • Does it handle Laravel’s autoloaded classes (e.g., Illuminate\Support\) correctly?
    • Are there false negatives (e.g., missing app/Providers/ or config/ analysis)?
  3. Performance:
    • How does it scale for large Laravel apps (e.g., 10K+ files)?
    • Does it support parallel processing or memory limits?
  4. Output reliability:
    • Can metrics be parsed programmatically (e.g., for a dashboard)?
    • Are there edge cases (e.g., Blade templates, PHP traits)?
  5. Maintenance:
    • Who responds to bug reports (e.g., Laravel 10+ compatibility)?
    • Is there a roadmap for Laravel-specific features?

Integration Approach

Stack Fit

  • Laravel-native:
    • Works seamlessly with Artisan commands (php artisan phploc).
    • No framework modifications required (unlike packages needing service providers).
  • CI/CD-friendly:
    • Can be gated in GitHub Actions/GitLab CI (e.g., block PRs if LOC > threshold).
    • Lightweight: Runs in <1s for small projects, <5s for large ones (test locally first).
  • DevOps tools:
    • Integrates with SonarQube (as a pre-step), CodeClimate, or custom dashboards.
  • Limitations:
    • No Laravel IDE plugins: Metrics must be manually reviewed or parsed.
    • No database storage: Requires external tools (e.g., a script to log outputs to a DB).

Migration Path

  1. Assessment Phase:
    • Install in a staging environment: composer require --dev cmgmyr/phploc.
    • Test on a representative Laravel project (e.g., a mid-sized app with app/, routes/, and database/).
    • Compare outputs with manual counts (e.g., wc -l app/*.php) for accuracy.
  2. CI Integration:
    • Add to .github/workflows/ci.yml:
      - name: Run PHPLOC
        run: php artisan phploc --log-junit > phploc-report.xml
      
    • Use JUnit output for CI failure thresholds (e.g., LOC > 50K).
  3. Dashboard Integration (Optional):
    • Parse CLI output with a PHP script and store in a DB (e.g., MySQL phploc_metrics table).
    • Example:
      $output = shell_exec('php artisan phploc --log-json');
      $metrics = json_decode($output, true);
      // Save to DB...
      
  4. Fallback Plan:
    • If cmgmyr/phploc fails, use the original sebastianbergmann/phploc (v8.0.6) with:
      composer require sebastianbergmann/phploc:^8.0
      ./vendor/bin/phploc app/
      

Compatibility

Factor Compatibility Risk
Laravel Versions Tested on Laravel 8+ (PHP 7.4–8.0). May fail on Laravel 5.7 (PHP 7.1). Medium
PHP Versions Supports 7.4–8.0 (aligns with Laravel 8–10). Low
Directory Structure Auto-detects app/, routes/, database/. Custom paths require --exclude. Low (configurable)
CI Systems Works with GitHub Actions, GitLab CI, Jenkins. Low
Monorepos May miscount if multiple Laravel apps share a vendor/ directory. High (requires --exclude)
Windows/Linux/macOS CLI tool; path separators may cause issues on Windows. Medium

Sequencing

  1. Phase 1: Proof of Concept (1 day)
    • Install and run on a small Laravel project.
    • Validate metrics against manual counts.
    • Check for false positives/negatives (e.g., Blade files, config files).
  2. Phase 2: CI Integration (2 days)
    • Add to CI pipeline with failure thresholds (e.g., LOC > 10% growth).
    • Test parallel runs (if using GitHub Actions).
  3. Phase 3: Dashboard (Optional, 3 days)
    • Parse output and store metrics in a DB.
    • Build a simple dashboard (e.g., Grafana, custom Laravel page).
  4. Phase 4: Monitoring (Ongoing)
    • Set up alerts for spikes in complexity.
    • Review quarterly reports for technical debt trends.

Operational Impact

Maintenance

  • Pros:
    • No Laravel core updates needed: Works as a standalone tool.
    • Minimal dependencies: Only requires PHP and Composer.
    • Self-contained: No external APIs or databases.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
ecotone/kafka
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata