PHPackages                             wnx/laravel-stats - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. wnx/laravel-stats

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

wnx/laravel-stats
=================

Get insights about your Laravel Project

v2.19.0(2mo ago)1.8k1.8M—2.5%847MITPHPPHP ^8.4CI passing

Since Oct 8Pushed 2mo ago21 watchersCompare

[ Source](https://github.com/stefanzweifel/laravel-stats)[ Packagist](https://packagist.org/packages/wnx/laravel-stats)[ Docs](https://github.com/stefanzweifel/laravel-stats)[ Fund](https://buymeacoff.ee/3oQ64YW)[ GitHub Sponsors](https://github.com/stefanzweifel)[ RSS](/packages/wnx-laravel-stats/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (26)Versions (64)Used By (7)

Laravel Stats
=============

[](#laravel-stats)

[ ![](https://camo.githubusercontent.com/48ec8f2783edfa91828a98edb94ce212f0fa9c1ac8c287cc436c32c0dac9bae4/68747470733a2f2f706f7365722e707567782e6f72672f776e782f6c61726176656c2d73746174732f762f737461626c65)](https://packagist.org/packages/wnx/laravel-stats)[ ![](https://github.com/stefanzweifel/laravel-stats/workflows/tests/badge.svg)](https://github.com/stefanzweifel/laravel-stats/actions?query=workflow%3A%22tests%22) [ ![](https://camo.githubusercontent.com/33124980b1a272394cdecdd664b94bca5e8c45ed43ba88eeee489b35ed229515/68747470733a2f2f706f7365722e707567782e6f72672f776e782f6c61726176656c2d73746174732f646f776e6c6f616473)](https://packagist.org/packages/wnx/laravel-stats)

 Get insights about your Laravel Project.

[![Screenshot](https://raw.githubusercontent.com/stefanzweifel/laravel-stats/master/screenshot.png)](https://raw.githubusercontent.com/stefanzweifel/laravel-stats/master/screenshot.png)

### Installing

[](#installing)

The easiest way to install the package is by using composer.

```
composer require "wnx/laravel-stats" --dev
```

The package will automatically register itself.

Optionally, you can publish the config file in your Laravel applications with the following command:

```
php artisan vendor:publish --provider="Wnx\LaravelStats\StatsServiceProvider"
```

Usage
-----

[](#usage)

After installing you can generate the statistics by running the following Artisan Command.

```
php artisan stats
```

(Make sure you run `php artisan config:clear` before running the above command.)

The statistics are also available as JSON.

```
php artisan stats --json
```

If you want a more detailed report and see which classes have been grouped into which component, you can use the `--verbose`-option.

```
php artisan stats --verbose

```

The verbose option is available for the JSON format also.

```
php artisan stats --json --verbose

```

> **Note**If your project is using [Pest PHP](https://pestphp.com) for writing tests, these files will automatically be excluded from the statistics. Due to how "laravel-stats" works internally, Pest PHP tests can't currently be detected. See [\#194](https://github.com/stefanzweifel/laravel-stats/discussions/194) for more information.

How does this package detect certain Laravel Components?
--------------------------------------------------------

[](#how-does-this-package-detect-certain-laravel-components)

The package scans the files defined in the `paths`-array in the configuration file. It then applies [Classifiers](https://github.com/stefanzweifel/laravel-stats/tree/master/src/Classifiers) to those classes to determine which Laravel Component the class represents.

ComponentClassificationLivewire ComponentsMust extend `Livewire\Component`ControllerMust be registered with a Route &amp; does not extend `Livewire\Component`ModelMust extend `Illuminate\Database\Eloquent\Model`CommandMust extend `Illuminate\Console\Command`RuleMust extend `Illuminate\Contracts\Validation\Rule`PolicyThe Policy must be registered in your `AuthServiceProvider`MiddlewareThe Middleware must be registered in your Http-KernelEventMust use `Illuminate\Foundation\Events\Dispatchable`-TraitEvent ListenerMust be registered for an Event in `EventServiceProvider`MailMust extend `Illuminate\Mail\Mailable`NotificationMust extend `Illuminate\Notifications\Notification`Nova ActionMust extend `Laravel\Nova\Actions\Action`Nova DashboardMust extend `Laravel\Nova\Dashboard`Nova FilterMust extend `Laravel\Nova\Filters\Filter`Nova LensMust extend `Laravel\Nova\Lenses\Lens`Nova ResourceMust extend `Laravel\Nova\Resource`JobMust use `Illuminate\Foundation\Bus\Dispatchable`-TraitMigrationMust extend `Illuminate\Database\Migrations\Migration`RequestMust extend `Illuminate\Foundation\Http\FormRequest`ResourceMust extend `Illuminate\Http\Resources\Json\JsonResource` or `Illuminate\Http\Resources\Json\ResourceCollection`SeederMust extend `Illuminate\Database\Seeder`ServiceProviderMust extend `Illuminate\Support\ServiceProvider`Blade ComponentsMust extend `Illuminate\View\Component`Custom CastsMust implement `Illuminate\Contracts\Database\Eloquent\CastsAttributes` or `Illuminate\Contracts\Database\Eloquent\CastsInboundAttributes`Database FactoryMust extend `Illuminate\Database\Eloquent\Factory`Dusk TestsMust extend `Laravel\Dusk\TestCase`BrowserKit TestMust extend `Laravel\BrowserKitTesting\TestCase`PHPUnit TestMust extend `PHPUnit\Framework\TestCase`Create your own Classifiers
---------------------------

[](#create-your-own-classifiers)

If your application has it's own components you would like to see in `laravel-stats` you can create your own "Classifiers". Create your own Classifiers by implementing the [`Classifier`](https://github.com/stefanzweifel/laravel-stats/blob/master/src/Contracts/Classifier.php)-contract and adding the class to the `stats.custom_component_classifier` config array.

For example:

```
// app/Classifiers/RepositoryClassifier.php
