PHP code example of wnx / laravel-stats

1. Go to this page and download the library: Download wnx/laravel-stats library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

wnx / laravel-stats example snippets


$app->register(\Wnx\LaravelStats\StatsServiceProvider::class);

// app/Classifiers/RepositoryClassifier.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

    ...
    'custom_component_classifier' => [
        \App\Classifiers\RepositoryClassifier::class
    ],
    ...
shell
php artisan vendor:publish --provider="Wnx\LaravelStats\StatsServiceProvider"
shell
php artisan stats
shell
php artisan stats --json

php artisan stats --verbose

php artisan stats --json --verbose