Laravel Stats 2.0 is Here

Packages

September 19th, 2019

Laravel Stats 2.0 was released recently with a bunch of changes and exciting features! If you’re not familiar, Laravel Stats is a rake-inspired package that gives you code statistics for your Laravel projects.

We originally covered Laravel Stats: Code Statistics for your Laravel Projects earlier this year, but it’s time to look at the shiny new features just released:

Differentiation between Application Code and Test Code

One of the stats is the ratio between application code and test code. In 2.0, each component can now be explicitly configured to count towards application or test code.

Verbose Mode

A new verbose flag (--verbose|-v) will list all the recognized classes for a component.

Filter Output by Component

A new --components flag was added to filter output by component type. An example of this flag is available in the readme:

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 ---+

You can see a list of component types in the project’s component classification table.

Learn More

If you are upgrading from a previous version or are curious for more 2.0 details, check out the notes for Release v2.0.0. You can learn more about this package, get full installation instructions, and view the source code on GitHub at stefanzweifel/laravel-stats.

Filed in:

Paul Redmond

Full stack web developer. Author of Lumen Programming Guide and Docker for PHP Developers.