Lines is a CLI tool by Tomas Votruba that measures lines of code and features used in PHP projects. It has zero dependencies, runs anywhere, and provides PHP-specific metrics such as the number of classes, the number of public methods, and more:
$ vendor/bin/lines measure app/ Filesystem count Directories ......................................... 32 Files .............................................. 160 Lines of code count / relative Code ................................... 15 521 / 70.9 % Comments ................................ 6 372 / 29.1 % Total .................................. 21 893 / 100 % Structure count Namespaces .......................................... 32 Classes ............................................ 134 * Constants ........................................ 91 * Methods ....................................... 1 114 Interfaces .......................................... 20 Traits ............................................... 4 Enums ................................................ 1 Functions ........................................... 36 Global constants ..................................... 0 Methods count / relative Non-static .............................. 1 058 / 95 % Static ..................................... 56 / 5 % Public .................................... 875 / 78.5 % Protected .................................. 90 / 8.1 % Private ................................... 149 / 13.4 %
It also includes JSON formatting for further processing, a PHP feature counter showing you which modern features your codebase uses, and other helpful insights.
Main Features
- Install anywhere - PHP 7.2? PHPUnit 6? Symfony 3? Not a problem, this package has zero dependencies and works on PHP 7.2+
- Project size - get quick overview of your project size - no details, no complexity, just lines of code
- JSON output - Get easy JSON output for further processing
- PHP Features - measure used PHP features in your project (i.e., how many PHP 8.0-features used, how many attributes, etc.)
🧑💻 You can get started with this package on GitHub: TomasVotruba/lines