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

Getting Started

  1. Install via Composer: composer require --dev cmgmyr/phploc
  2. Run the Artisan command: php artisan phploc — this outputs key metrics (LOC, classes, methods, functions, files) for your current Laravel project.
  3. For a quick first look, check the output summary — it defaults to the app/, routes/, and database/ directories, which covers most Laravel code.
  4. Review the phploc documentation for full metric definitions (e.g., LLOC, CCR, WMC) — this package uses those internally and surfaces them directly.

Implementation Patterns

  • Ad-hoc analysis: Use php artisan phploc during development to get immediate feedback on code growth — e.g., after adding a big feature or refactoring.
  • CI integration: Add the command to your CI pipeline (php artisan phploc --ci) to capture metrics over time. Use the --log-csv or --log-json options to export results (e.g., php artisan phploc --log-json=phploc-report.json) for reporting or trend dashboards.
  • Baseline tracking: Save output to version control (e.g., phploc-summary.txt) and compare across branches or commits with git diff.
  • Customize scope: Override default paths via config (php artisan vendor:publish --provider="Cmgmyr\Phploc\PhplocServiceProvider") to exclude tests (tests/) or include config/ or database/ more explicitly.

Gotchas and Tips

  • phploc CLI dependency: The package requires the phploc CLI to be installed globally (e.g., via PHAR or Composer) — ensure it’s on $PATH. The Artisan command fails if not found; check via phploc --version outside Laravel.
  • Working directory sensitivity: The tool resolves paths relative to the project root (where artisan runs). If you use php artisan phploc from a subdirectory (e.g., app/Console), use cd .. && php artisan phploc or configure paths explicitly in config.
  • Excluding logs/cache: Add storage/ and bootstrap/cache/ to your phploc.php config (or pass --exclude) to avoid counting auto-generated files and logs — those bloat LOC without meaningful metrics.
  • CI-friendly flags: Use --min-coverage=0 (or omit coverage-related flags) — Laravel apps rarely track test coverage in pure LOC analysis; leaving defaults may cause phploc to fail if no coverage data exists.
  • Long-term trends: Record daily metrics in a time-series DB (e.g., InfluxDB) or log to CSV and plot with tools like Grafana. Example: php artisan phploc --log-csv=phploc-latest.csv --exclude=tests → append to a rolling log for trend analysis.
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.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport
twbs/bootstrap4
php-http/client-implementation
phpcr/phpcr-implementation
cucumber/gherkin-monorepo
haydenpierce/class-finder
psr/simple-cache-implementation
uri-template/tests