All Projects β†’ stefanzweifel β†’ Laravel Stats

stefanzweifel / Laravel Stats

Licence: mit
πŸ“ˆ Get insights about your Laravel or Lumen Project

Projects that are alternatives of or similar to Laravel Stats

Jwt Auth Guard
JWT Auth Guard for Laravel and Lumen Frameworks.
Stars: ✭ 319 (-76.98%)
Mutual labels:  laravel, laravel-package, composer
Eloquent Tree
Eloquent Tree is a tree model for Laravel Eloquent ORM.
Stars: ✭ 131 (-90.55%)
Mutual labels:  laravel, laravel-package, composer
Laravel Server Monitor
Server Monitoring Command for Laravel Applications
Stars: ✭ 424 (-69.41%)
Mutual labels:  laravel, laravel-package, composer
Telegram Bot Sdk
πŸ€– Telegram Bot API PHP SDK. Lets you build Telegram Bots easily! Supports Laravel out of the box.
Stars: ✭ 2,212 (+59.6%)
Mutual labels:  laravel, laravel-package, composer
Package Skeleton
πŸ“¦ My base for PHP packages.
Stars: ✭ 6 (-99.57%)
Mutual labels:  laravel, laravel-package, composer
Laravel Schedule List
Laravel package to add command to list all scheduled artisan commands
Stars: ✭ 84 (-93.94%)
Mutual labels:  laravel, laravel-package
Bigbluebutton
Package that provides easily communicate between bigbluebutton server and laravel framework
Stars: ✭ 85 (-93.87%)
Mutual labels:  laravel, laravel-package
Laravel Id Generator
Easy way to generate custom ID from database table in Laravel framework.
Stars: ✭ 88 (-93.65%)
Mutual labels:  laravel, laravel-package
Elasticsearch Eloquent
⚑️ Eloquent models for Elasticsearch.
Stars: ✭ 100 (-92.78%)
Mutual labels:  laravel, laravel-package
Laravel Console Logger
Logging and Notifications for Laravel Console Commands.
Stars: ✭ 79 (-94.3%)
Mutual labels:  laravel, laravel-package
Laravel Sync Migration
Developer tool helps to sync migrations without refreshing the database
Stars: ✭ 89 (-93.58%)
Mutual labels:  laravel, laravel-package
Dropzone Laravel Image Upload
Laravel 5.2 and Dropzone.js auto image uploads with removal links
Stars: ✭ 92 (-93.36%)
Mutual labels:  laravel, laravel-package
Project
⭐️ Antares Project Application Skeleton. This is the very first place you should start. It allows you to create a brand new awesome project in easy few steps.
Stars: ✭ 84 (-93.94%)
Mutual labels:  laravel, composer
Laravel Sitemap
Laravelium Sitemap generator for Laravel.
Stars: ✭ 1,231 (-11.18%)
Mutual labels:  laravel, composer
Docker Laravel
Laravel 5 with Dockerized Gulp, PHP-FPM, MySQL and nginx using docker-compose
Stars: ✭ 85 (-93.87%)
Mutual labels:  laravel, composer
Laravel Url Shortener
Powerful URL shortening tools in Laravel
Stars: ✭ 80 (-94.23%)
Mutual labels:  laravel, laravel-package
Laravel Rest Api
Powerful RestAPI plugin for Laravel
Stars: ✭ 90 (-93.51%)
Mutual labels:  laravel, laravel-package
Admin One Laravel Dashboard
Admin One β€” Free Laravel Dashboard (Bulma Buefy Vue.js SPA)
Stars: ✭ 94 (-93.22%)
Mutual labels:  laravel, laravel-package
Laravel Backup
A easy-to-use backup manager for Laravel
Stars: ✭ 93 (-93.29%)
Mutual labels:  laravel, composer
Lara Lens
Laravel package for display diagnostic (config, database, http connections...)
Stars: ✭ 96 (-93.07%)
Mutual labels:  laravel, laravel-package

Laravel Stats

Buy us a tree

Get insights about your Laravel or Lumen Project.

Screenshot

Installing

The easiest way to install the package is by using composer. The package requires PHP 7.3, Laravel 6.0 or higher or Lumen 6.0 or higher.

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

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.

Component Classification
Controller Must be registered with a Route
Model Must extend Illuminate\Database\Eloquent\Model
Command Must extend Illuminate\Console\Command
Rule Must extend Illuminate\Contracts\Validation\Rule
Policy The Policy must be registered in your AuthServiceProvider
Middleware The Middleware must be registered in your Http-Kernel
Event Must use Illuminate\Foundation\Events\Dispatchable-Trait
Event Listener Must be registered for an Event in EventServiceProvider
Mail Must extend Illuminate\Mail\Mailable
Notification Must extend Illuminate\Notifications\Notification
Nova Action Must extend Laravel\Nova\Actions\Action
Nova Dashboard Must extend Laravel\Nova\Dashboard
Nova Filter Must extend Laravel\Nova\Filters\Filter
Nova Lens Must extend Laravel\Nova\Lenses\Lens
Nova Resource Must extend Laravel\Nova\Resource
Job Must use Illuminate\Foundation\Bus\Dispatchable-Trait
Migration Must extend Illuminate\Database\Migrations\Migration
Request Must extend Illuminate\Foundation\Http\FormRequest
Resource Must extend Illuminate\Http\Resources\Json\JsonResource or Illuminate\Http\Resources\Json\ResourceCollection
Seeder Must extend Illuminate\Database\Seeder
ServiceProvider Must extend Illuminate\Support\ServiceProvider
Blade Components Must extend Illuminate\View\Component
Custom Casts Must implement Illuminate\Contracts\Database\Eloquent\CastsAttributes or Illuminate\Contracts\Database\Eloquent\CastsInboundAttributes
Database Factory Must extend Illuminate\Database\Eloquent\Factory
Dusk Tests Must extend Laravel\Dusk\TestCase
BrowserKit Test Must extend Laravel\BrowserKitTesting\TestCase
PHPUnit Test Must extend PHPUnit\Framework\TestCase

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
    ],
    ...

Share Metrics with the Laravel Community

You can optionally share your projects statistic by using the --share option.

php artisan stats --share

Your project statistics is shared anonymously with stats.laravelshift.com. In regular intervals the dashboard and charts on the site are updated with shared data from other Laravel projects.

To learn more about this feature, please check out PR #178.

Share statistic through CI

If you would like to share your project statistic in a CI environment you can use the --no-interaction and --name-options.

Use the following command in your CI script to share your project statistic automatically. (Update org/repo with the name of your application (eg. acme/podcasting-app))

php artisan stats --share --no-interaction --name=org/repo

If you're code is hosted on GitHub, you can integrate stats with GitHub Actions. Copy the following Workflow to .github/workflows/laravel-stats.yml. It will share data when a commit is pushed to the master branch. The Action automatically uses your GitHub repository name in the --name-option.

name: stats

on:
  push:
    branches:
      - master

jobs:
  stats:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/[email protected]

      - name: Setup PHP
        uses: shivammathur/[email protected]
        with:
          php-version: 7.4
          tools: composer:v2

      - name: Install dependencies
        run: composer install --prefer-dist --no-interaction --no-suggest

      - name: Share Stats
        run: php artisan stats --share --name=$GITHUB_REPOSITORY --no-interaction

Inspect Data shared with the Community

If you would like to inspect the payload the command is sending to the API you can use the --dry-run and --payload options.

php artisan stats --share  --no-interaction  --name="org/repo" --dry-run --payload

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].