当前位置: 首页 > 软件库 > Web应用开发 > Web框架 >

laravel-stats

授权协议 MIT License
开发语言 PHP
所属分类 Web应用开发、 Web框架
软件类型 开源软件
地区 不详
投 递 者 况庆
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

Laravel Stats

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/checkout@v2

      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        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.

  • 原文地址: Laravel Mix Docs ps:这个版本是 3.0 文档, 大部分功能和 4.0 一致 概览 基本示例 larave-mix 是位于webpack顶层的一个简洁的配置层,在 80% 的情况下使用 laravel mix 会使操作变的非常简单。尽管 webpack 非常的强大,但大部分人都认为 webpack 的学习成本非常高。但是如果你不必用再担心这些了呢? 看一下基本的 we

  • 在https://github.com/fex-team/webuploader 下载webuploader并解压, 解压后放到public里面。其中我把解压缩后的文件夹改名为webuploader,放到了public/文件夹下。 将你放到public下的webuploader文件夹中的examples/imageupload/index.html复制到在对应需要文件上传功能的视图文件夹下面 将其

  • debugbar barryvdh/laravel-debugbar ide-helper barryvdh/laravel-ide-helper 项目代码统计(文件数/行数) wnx/laravel-stats 代码规范检测 squizlabs/php_codesniffer 原本的测试如果使用了 browser kit 的话,可以选择升级到 Laravel Dusk 或者加载原有的扩展包 la

  • 一、快速开始 laravel 安装es composer require elasticsearch/elasticsearch 环境配置 .env ELASTIC_HOST=192.168.20.129:9200 # 这里是你的 ElasticSearch 服务器 IP 及端口号 ELASTIC_LOG_INDEX=bf_log # ElasticSearch 索引 ELASTIC_LOG_T

  • 简介 ___ _ _ / __) _ | | | | | |__ ____ ___| |_ | | ____ ____ ____ _ _ ____| | | __) _ |/___) _) | |/ _ |/ ___) _ | | | / _ ) | | | ( ( | |___ | |__ | ( ( | | | ( ( | |\ V ( (/ /| | |_| \_||_(___/ \___)

  • 一、添加回复 1. 增加路由 只有登录用户才可以进行回复 routes/api.php . . . //删除话题下方增加 $api->delete('topics/{topic}', 'TopicsController@destroy') ->name('api.topics.destroy'); //发布回复

  • 这次给大家带来使用Laravel/Lumen的图文详解,使用Laravel/Lumen的注意事项有哪些,下面就是实战案例,一起来看一下。 LaravelS - 站在巨人的肩膀上 本文主要介绍了LaravelS通过Swoole加速Laravel/Lumen的相关内容,关于:rocket: 通过Swoole来加速 Laravel/Lumen,其中的S代表Swoole,速度,高性能。 特性高性能的Swo

  • 当执行了npm run dev命令来编译前端资源时,经常会遇到一个报错,类似这样: > Code@1.0.0 dev /home/vagrant/Code > cross-env NODE_ENV=development webpack --progress --hide-modules sh: 1: cross-env: not found npm ERR! Linux 4.4.0-51-g

  • 关于laravel的单元测试记录-----控制器部分 测试laravel 的控制器层会涉及到Requst对象,故而得构造Request,尝试两种解决方案。 解决方案 模拟http请求 构造Request 实现 模拟http请求 该方法需要运行http服务。 /** * 封装公共请求方法 * @param $method * @param $url *

  • 上一篇简单介绍了什么是 Laravel 广播,本篇我们来剖析一下 Laravel 广播的原理,以及使用时的注意事项。 正好看到一篇老外写的搭建攻略,也非常不错: https://medium.com/@dennissmink/laravel-echo-server-how-to-24d5778ece8b 开始使用 Laravel App Server - 应用服务端 修改 .env 的 BROAD

 相关资料
  • Laravel 是一套简洁、优雅的PHP Web开发框架(PHP Web Framework)。它可以让你从面条一样杂乱的代码中解脱出来;它可以帮你构建一个完美的网络APP,而且每行代码都可以简洁、富于表达力。 功能特点 1、语法更富有表现力 你知道下面这行代码里 “true” 代表什么意思么? $uri = Uri::create(‘some/uri’, array(), array(), tr

  • 我需要空间/Laravel权限的帮助。当我试图分配它给我错误哎呀,看起来像出了问题。 错误 Connection.php第761行中的QueryExcema:SQLSTATE[23000]:完整性约束冲突:1048列role_id不能为空(SQL:插入到(,)值(9,))

  • Laravel 作为现在最流行的 PHP 框架,其中的知识较多,所以单独拿出来写一篇。 简述 Laravel 的生命周期 Laravel 采用了单一入口模式,应用的所有请求入口都是 public/index.php 文件。 注册类文件自动加载器 : Laravel通过 composer 进行依赖管理,无需开发者手动导入各种类文件,而由自动加载器自行导入。 创建服务容器:从 bootstrap/ap

  • 简介 Laravel Scout 为 Eloquent 模型 全文搜索提供了简单的,基于驱动的解决方案。通过使用模型观察者,Scout 会自动同步 Eloquent 记录的搜索索引。 目前,Scout 自带一个 Algolia 驱动;不过,编写自定义驱动很简单, 你可以轻松的通过自己的搜索实现来扩展 Scout。 安装 首先,通过 Composer 包管理器来安装 Scout: composer

  • 简介 Laravel 致力于让整个 PHP 开发体验变得愉快, 包括你的本地开发环境。 Vagrant 提供了一种简单,优雅的方式来管理和配置虚拟机。 Laravel Homestead 是一个官方预封装的 Vagrant box,它为你提供了一个完美的开发环境,而无需在本地机器安装 PHP 、Web 服务器和其他服务器软件。不用担心会搞乱你的操作系统!Vagrant boxes 是一次性的。如果

  • WebStack-Laravel 一个开源的网址导航网站项目,具备完整的前后台,您可以拿来制作自己的网址导航。 部署 克隆代码: git clone https://github.com/hui-ho/WebStack-Laravel.git 安装依赖: composer installphp artisan key:generate 编辑配置: cp .env.example .env ...D