wnx / laravel-stats
Get insights about your Laravel Project
Fund package maintenance!
stefanzweifel
buymeacoff.ee/3oQ64YW
Installs: 1 412 131
Dependents: 7
Suggesters: 0
Security: 0
Stars: 1 728
Watchers: 25
Forks: 87
Open Issues: 0
Requires
- php: ^8.2
- ext-json: *
- illuminate/console: ^11.0
- illuminate/support: ^11.0
- stefanzweifel/laravel-stats-phploc: ^7.0 | ^8.0
- symfony/finder: ^7.0
- symfony/process: ^7.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.2
- larastan/larastan: ^2.0
- laravel/browser-kit-testing: ^7.1 | ^8.0
- laravel/dusk: ^8.0
- livewire/livewire: ^3.0
- orchestra/testbench: ^9.0
- pestphp/pest: ^2
- phpunit/phpunit: ^10.0 | ^11.0
- rector/rector: ^1.0
- dev-main
- v2.14.0
- v2.13.2
- v2.13.1
- v2.13.0
- v2.12.0
- v2.11.4
- v2.11.3
- v2.11.2
- v2.11.1
- v2.11.0
- v2.10.0
- v2.9.2
- v2.9.1
- v2.9.0
- v2.8.1
- v2.8.0
- v2.7.0
- v2.6.0
- v2.5.2
- v2.5.1
- v2.5.0
- v2.4.1
- v2.4.0
- v2.3.0
- v2.2.0
- v2.1.1
- v2.1.0
- v2.0.2
- v2.0.1
- v2.0.0
- v1.x-dev
- v1.9.2
- v1.9.1
- v1.9.0
- v1.8.3
- v1.8.2
- v1.8.1
- v1.8.0
- v1.7.2
- v1.7.1
- v1.7.0
- v1.6.1
- v1.6.0
- v1.5.0
- v1.4.0
- v1.3.3
- v1.3.2
- v1.3.1
- v1.3.0
- v1.2.0
- v1.1.1
- v1.1.0
- v1.0.0
- v1.0.0-beta-2
- v1.0.0-beta
- dev-php-84
- dev-metrics
This package is auto-updated.
Last update: 2024-11-13 18:24:05 UTC
README
Get insights about your Laravel or Lumen Project.
Installing
The easiest way to install the package is by using composer.
composer require "wnx/laravel-stats" --dev
The package will automatically register itself.
If you're using Lumen you have to manually register the Service Provider in your bootstrap/app.php
file:
$app->register(\Wnx\LaravelStats\StatsServiceProvider::class);
Optionally, you can publish the config file in your Laravel applications with the following command:
php artisan vendor:publish --provider="Wnx\LaravelStats\StatsServiceProvider"
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 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 for more information.
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 to those classes to determine which Laravel Component the class represents.
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
-contract and adding the class to the stats.custom_component_classifier
config array.
For example:
// app/Classifiers/RepositoryClassifier.php <?php namespace App\Classifiers; use Wnx\LaravelStats\ReflectionClass; use Wnx\LaravelStats\Contracts\Classifier; class RepositoryClassifier implements Classifier { public function name(): string { return 'Repositories'; } public function satisfies(ReflectionClass $class): bool { return $class->isSubclassOf(\App\Repositories\BaseRepository::class); } public function countsTowardsApplicationCode(): bool { return true; } public function countsTowardsTests(): bool { return false; } }
// config/stats.php <?php ... 'custom_component_classifier' => [ \App\Classifiers\RepositoryClassifier::class ], ...
Treeware
You're free to use this package, but if it makes it to your production environment you are required to buy the world a tree.
It’s now common knowledge that one of the best tools to tackle the climate crisis and keep our temperatures from rising above 1.5C is to plant trees. If you support this package and contribute to the Treeware forest you’ll be creating employment for local families and restoring wildlife habitats.
You can buy trees here offset.earth/treeware
Read more about Treeware at treeware.earth
Running the tests
The package has tests written in phpunit. You can run them with the following command.
./vendor/bin/phpunit
Running the command in a local test project
If you're working on the package locally and want to just run the command in a demo project you can use the composer path-repository format.
Add the following snippet to the composer.json
in your demo project.
{ "repositories": [ { "type": "path", "url": "/path/to/laravel-stats/", "options": { "symlink": true } } ], }
And "install" the package with composer require wnx/laravel-stats
. The package should now be symlinked in your demo project.
Versioning
We use SemVer for versioning. For the versions available, see the tags on this repository.
Credits
License
This project is licensed under the MIT License - see the LICENSE file for details.