Laravel Stats Versions Save

📈 Get insights about your Laravel or Lumen Project

v2.4.1

3 years ago

Changed

  • Use latest version of stefanzweifel/laravel-stats-phploc (Remove deprecated sebastian/finder-facade dependency) #185, #184

v2.4.0

3 years ago

Added

  • Add Database Factory Classifier #183
  • Add Support for Laravel 8 #180

v2.3.0

3 years ago

I'm thrilled to release v2.3.0 of laravel-stats. 🎉

A quick overview of what has changed in this version.

  • Support for Model Observers has been added. (#177, #128)
  • A new --share option has been added (see below for more information) #178
  • Support for Laravel 6 and PHPUnit 8 has been added back. (Was previously removed in v2.1.0)

New --share option

v2.3.0 comes with a new --share-option for the stats-command.

By executing php artisan stats --share your project statistics are shared anonymously with the Laravel community. Your statistics will be combined with other Laravel projects to provide metrics available on stats.laravelshift.com.

The stats command will never automatically share anything! Only when this option is used and you confirm the prompts will data be shared.

What does this mean in detail?

By executing php artisan stats --share you can opt-in to share the used components and its statistical numbers like "number of classes" and "lines of code per component" with the Laravel community on stats.laravelshift.com.

Jason McCreary, the creator of Shift, and I developed this feature from an idea we had 2 years ago after Jason gave his "Laravel by the Numbers" talk at Laracon US 2018.

Our goal is to collect and aggregate statistical data from Laravel projects and transform the raw data into an easy-to-read dashboard for the Laravel community.

We hope it to make it easier for you as a developer to make decisions when crafting your Laravel projects. For example: "How many projects use Blade Components?" or "How many projects have a Models folder?"

What is being shared?

The request sent to the API contains:

  • the project name you've defined (used internally as a unique identifier)
  • a list of components and their statistical numbers in your projects. (e.g. controllers_lloc_per_method or phpunit_tests)

Class names or code will never be shared. If you would like to see the exact payload which is sent to the API, you may use the --payload option. You may also use the --dry-run option to prevent sending a request to the API.

For example, the following command will simulate sharing your project stats with the API and output the data to that would be sent:

php artisan stats --share --payload --dry-run

v2.2.0

4 years ago

Added

  • Add Blade Components Classifier #169, #173
  • Add Custom Casts Classifier #168, #174

v2.1.1

4 years ago

Removed

  • Drop support for phpunit 8.0

v2.1.0

4 years ago

Note: Due to underlying changes to the phploc-dependency, the numbers for "loc" and "lloc" in your project may change.

Changed

  • Run test suite against Laravel 7 #170

Removed

  • Removed support to detect Illuminate\Http\Resources\Json\Resource as an API resource #170
  • Dropped support for Laravel 5.8 #170
  • Dropped support for Laravel 6.0 #170
  • Dropped support for PHP 7.2 #170

v2.0.1

4 years ago

Added

  • Add Laravel Nova Dashboard Classifier #158, #159
  • Add php-cs-fixer GitHub Actions workflow #160

Changed

  • Test Package against Laravel 6.0 #155
  • Set declare(strict_types=1) everywhere #161
  • Changed Version Contraints in composer.json to support Laravel 7.0
  • Changed Version Contraints for phpunit/phpunit to support 9.0

Fixed

  • Make ControllerClassifier compatible with Lumen 6.0 2462fe
  • Fix an Issue in ResourceClassifier where not all kinds of Resources were correctly identified as API Resources #156

v2.0.2

4 years ago

Changed

  • Changed Version Contraints for phploc/phploc to support 6.0 #167

v2.0.0

4 years ago

Almost 2 years after the first major release of stats I'm thrilled to release 2.0. 🎉

Under the hood a lot has changed: Many internal classes have been rewritten to pave the path for new cool features (more about them soon). Performance for bigger projects with more than 1000 classes has also been improved, by using more caches internally.

On the side of breaking changes, support for older PHP, Laravel and Lumen versions has been removed. Also checkout the "Upgrade Guide" below to see, if your apps works as intended with version 2.0.

New Features

Differentiation between Application Code and Test Code

One of the statistics stats shows you, is the ratio between application code and test code. The previous versions had a naive approach of determining if a class belongs to the application or test code (If the class wasn't a test, it counted towards the application code).
In 2.0, each Component can now be explicitly be configured to count towards application or test code.

For example all Laravel Nova Classifiers (Actions, Filters, Lenses and Resources) have been configured to NOT count towards the application AND NOT towards the test code.
If you disagree with this decision, feel free to open an issue. Im open for discussions!

Verbose Mode

Previously, it was impossible to see which classes have been classified as "Others". Version 2.0 now supports a verbose option – triggered by adding -v or --verbose to the command call – which will list all recognized classes for a component.

Example output for a fresh Laravel 6.0 app:

php artisan stats --verbose
+----------------------------+----------------------------+---------+---------------+-----+------+-------------+
| Name                       |                    Classes | Methods | Methods/Class | LoC | LLoC | LLoC/Method |
+----------------------------+----------------------------+---------+---------------+-----+------+-------------+
| Middlewares                |                          7 |       2 |          0.29 | 146 |   26 |          13 |
| - App\Http\Middleware\VerifyCsrfToken                   |       0 |             0 |  24 |    4 |           0 |
| - App\Http\Middleware\RedirectIfAuthenticated           |       1 |             1 |  26 |    5 |           5 |
| - App\Http\Middleware\TrimStrings                       |       0 |             0 |  18 |    3 |           0 |
| - App\Http\Middleware\Authenticate                      |       1 |             1 |  21 |    3 |           3 |
| - App\Http\Middleware\TrustProxies                      |       0 |             0 |  23 |    5 |           0 |
| - App\Http\Middleware\CheckForMaintenanceMode           |       0 |             0 |  17 |    3 |           0 |
| - App\Http\Middleware\EncryptCookies                    |       0 |             0 |  17 |    3 |           0 |
+----------------------------+----------------------------+---------+---------------+-----+------+-------------+
| Migrations                 |                          3 |       6 |             2 | 103 |   31 |        5.17 |
| - CreatePasswordResetsTable                             |       2 |             2 |  32 |    8 |           4 |
| - CreateUsersTable                                      |       2 |             2 |  36 |   12 |           6 |
| - CreateFailedJobsTable                                 |       2 |             2 |  35 |   11 |         5.5 |
+----------------------------+----------------------------+---------+---------------+-----+------+-------------+
| Models                     |                          1 |       0 |             0 |  39 |    8 |           0 |
| - App\User                                              |       0 |             0 |  39 |    8 |           0 |
+----------------------------+----------------------------+---------+---------------+-----+------+-------------+
| Seeders                    |                          1 |       1 |             1 |  16 |    1 |           1 |
| - DatabaseSeeder                                        |       1 |             1 |  16 |    1 |           1 |
+----------------------------+----------------------------+---------+---------------+-----+------+-------------+
| Service Providers          |                          5 |       9 |           1.8 | 186 |   28 |        3.11 |
| - App\Providers\AppServiceProvider                      |       2 |             2 |  28 |    2 |           1 |
| - App\Providers\AuthServiceProvider                     |       1 |             1 |  30 |    5 |           5 |
| - App\Providers\EventServiceProvider                    |       1 |             1 |  34 |    7 |           7 |
| - App\Providers\RouteServiceProvider                    |       4 |             4 |  73 |    9 |        2.25 |
| - App\Providers\BroadcastServiceProvider                |       1 |             1 |  21 |    5 |           5 |
+----------------------------+----------------------------+---------+---------------+-----+------+-------------+
| PHPUnit Tests              |                          3 |       2 |          0.67 |  50 |   12 |           6 |
| - Tests\TestCase                                        |       0 |             0 |  10 |    3 |           0 |
| - Tests\Unit\ExampleTest                                |       1 |             1 |  19 |    4 |           4 |
| - Tests\Feature\ExampleTest                             |       1 |             1 |  21 |    5 |           5 |
+----------------------------+----------------------------+---------+---------------+-----+------+-------------+
| Other                      |                          9 |      11 |          1.22 | 410 |   61 |        5.55 |
| - App\Console\Kernel                                    |       2 |             2 |  42 |    6 |           3 |
| - App\Exceptions\Handler                                |       2 |             2 |  51 |    7 |         3.5 |
| - App\Http\Controllers\Controller                       |       0 |             0 |  13 |    6 |           0 |
| - App\Http\Controllers\Auth\ForgotPasswordController    |       1 |             1 |  32 |    5 |           5 |
| - App\Http\Controllers\Auth\LoginController             |       1 |             1 |  39 |    6 |           6 |
| - App\Http\Controllers\Auth\ResetPasswordController     |       1 |             1 |  39 |    6 |           6 |
| - App\Http\Controllers\Auth\RegisterController          |       3 |             3 |  72 |   11 |        3.67 |
| - App\Http\Controllers\Auth\VerificationController      |       1 |             1 |  41 |    8 |           8 |
| - App\Http\Kernel                                       |       0 |             0 |  81 |    6 |           0 |
+----------------------------+----------------------------+---------+---------------+-----+------+-------------+
+----------------------------+----------------------------+---------+---------------+-----+------+-------------+
| Total                      |                         29 |      31 |          1.07 | 950 |  167 |        5.39 |
+-------------------- Code LLoC: 155 • Test LLoC: 12 • Code/Test Ratio: 1:0.1 • Routes: 2 +------+-------------+

Filter output by Components

It's now possible to filter the output for certain components.

php artisan stats --components=Migrations,Models
+------------+---------+---------+---------------+-----+------+-------------+
| Name       | Classes | Methods | Methods/Class | LoC | LLoC | LLoC/Method |
+------------+---------+---------+---------------+-----+------+-------------+
| Migrations |       3 |       6 |             2 | 103 |   31 |        5.17 |
| Models     |       1 |       0 |             0 |  39 |    8 |           0 |
+------------+---------+---------+---------------+-----+------+-------------+
| Total      |      29 |      31 |          1.07 | 950 |  167 |        5.39 |
+--- Code LLoC: 155 • Test LLoC: 12 • Code/Test Ratio: 1:0.1 • Routes: 2 ---+

Upgrade Guide

Update configuration file

Impact: All users, Effort: Low

Laravel 6.0 comes with a new tests/bootstrap.php file. If you have an existing app which has been updated to Laravel 6.0, add the file to the exclude-key in config/stats.php to improve the performance of artisan stats.

    'exclude' => [
+        base_path('tests/bootstrap.php'),
        // base_path('app/helpers.php'),
        // base_path('app/Services'),
    ],

Update Custom Component Classifiers

Impact: Moderate, Effort: Moderate

The Classifier-contract has been updated:

  • Return Type Hints have been declared for all methods in the contract.
  • The getName() method has been renamed to name().
  • The countsTowardsApplicationCode() has been added. The method must return a boolean and indicates, if the given component should count towards the application code. This piece of information is used in the calculation of the "Code to Test ratio".
  • The countsTowardsTests() has been added. The method must return a boolean and indicates, if the given component should count towards the test code. This piece of information is used in the calculation of the "Code to Test ratio".

If you've defined your own Custom Components, you have to update your implementations to meet the new criterias.

v1.9.1

5 years ago
  • Fix compatibility issues with Lumen #139