Repolode
stefanzweifel

stefanzweifel/laravel-stats

A Composer dev package for Laravel and Lumen that counts your app's code and classifies classes by Laravel component.

Stars
1,741
Forks
84
Open issues
0
Last commit
14 days ago

What is it?

Laravel Stats is a Composer package that scans a Laravel or Lumen project and produces an overview of its codebase. It reports how much code the application contains and breaks the classes down by Laravel component, such as controllers, models, jobs, migrations, and Livewire components.

Classification is based on what each class extends, implements, or uses, plus checks such as whether a controller is registered with a route or a policy is registered in the auth service provider. The scanned paths come from the package config file. You can also write custom classifiers that implement the Classifier contract to group your own component types, such as repositories.

The command runs as `php artisan stats`, with `--json` for machine-readable output and `--verbose` to show which classes fall into each component. Tests written with Pest are excluded from the statistics.

Key features

  • 01Counts lines of code for application code and tests.
  • 02Groups classes by Laravel component such as controllers, models, and jobs.
  • 03Outputs results as a table or JSON.
  • 04Verbose mode lists which classes belong to each component.
  • 05Supports custom classifiers for application-specific component types.

Use cases

  • Getting a quick overview of a legacy Laravel codebase's structure.
  • Tracking how the number of components in an application changes over time.
  • Feeding project statistics into scripts or reports via JSON output.

Quick start

  1. 1

    Install the package as a dev dependency with Composer

    composer require "wnx/laravel-stats" --dev
  2. 2

    Clear the config cache before running (recommended)

    php artisan config:clear
  3. 3

    Generate the statistics in your Laravel project

    php artisan stats

Things to know

  • Targets Laravel and Lumen projects only, so it is not useful for other PHP frameworks.
  • Pest PHP tests cannot currently be detected and are excluded from the statistics.

In collections

Topics

#laravel#php#code-statistics#composer-package#static-analysis#code-metrics#composer#laravel-package#statistics

FAQ

What is laravel-stats?
A Composer dev package for Laravel and Lumen that counts your app's code and classifies classes by Laravel component. Laravel Stats is a Composer package that scans a Laravel or Lumen project and produces an overview of its codebase. It reports how much code the application contains and breaks the classes down by Laravel component, such as controllers, models, jobs, migrations, and Livewire components.
Is laravel-stats free to use? What license does it have?
laravel-stats is open source under the MIT license. Check the license terms before using it in commercial products.
Is laravel-stats still maintained?
Actively maintained. The last commit to laravel-stats was on Oct 24, 2026.
What can I use laravel-stats for?
Getting a quick overview of a legacy Laravel codebase's structure. Tracking how the number of components in an application changes over time. Feeding project statistics into scripts or reports via JSON output.
How do I install laravel-stats?
Install the package as a dev dependency with Composer: composer require "wnx/laravel-stats" --dev Clear the config cache before running (recommended): php artisan config:clear Generate the statistics in your Laravel project: php artisan stats
Where can I get laravel-stats?
The source code and installation instructions are on GitHub: https://github.com/stefanzweifel/laravel-stats

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects