• Stars
    star
    163
  • Rank 231,141 (Top 5 %)
  • Language
    PHP
  • License
    MIT License
  • Created over 1 year ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

CLI tool for quick size measure of PHP project, runs anywhere

Lines

CLI tool for quick size measure of PHP project, runs anywhere

What are killer features?

  • install anywhere - PHP 7.2? PHPUnit 6? Symfony 3? Not a problem, this package has zero dependencies and works on PHP 7.2+
  • get quick overview of your project size - no details, no complexity, just lines of code
  • get easy JSON output for further processing
  • we keep it simple, so you can enjoy reading - for more complex operation use static analysis like PHPStan

Install

The package is scoped and downgraded to PHP 7.2. So you can install it anywhere with any set of dependencies:

composer require tomasvotruba/lines --dev

Usage

vendor/bin/lines measure src

For short output:

vendor/bin/lines measure src --short

For json output, just add --json:

vendor/bin/lines measure src --json

Also, you can combine them (very handy for blog posts and tweets):

vendor/bin/lines measure src --short --json

The Measured Items

For the text output, you'll get data like these:

  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 %

Or in a json format:

{
    "filesystem": {
        "directories": 10,
        "files": 15
    },
    "lines_of_code": {
        "code": 1064,
        "code_relative": 95.4,
        "comments": 51,
        "comments_relative": 4.6,
        "total": 1115
    },
    "structure": {
        "namespaces": 11,
        "classes": 14,
        "class_methods": 88,
        "class_constants": 0,
        "interfaces": 1,
        "traits": 0,
        "enums": 0,
        "functions": 5,
        "global_constants": 3
    },
    "methods_access": {
        "non_static": 82,
        "non_static_relative": 93.2,
        "static": 6,
        "static_relative": 6.8
    },
    "methods_visibility": {
        "public": 70,
        "public_relative": 79.5,
        "protected": 2,
        "protected_relative": 2.3,
        "private": 16,
        "private_relative": 18.2
    }
}

Vendor file scanning

This tool use case is to measure your code, not the 3rd party libraries. That's why it ignores /vendor directory by default to avoid huge false positives.

If you want to measure vendor files too, use --allow-vendor option:

 vendor/bin/lines measure vendor/rector/rector --allow-vendor

More Repositories

1

bladestan

PHPStan analysis for Blade templates
PHP
288
star
2

awesome-php-migrations

Awesome sources for PHP projects migrations - legacy, pattern refactoring, framework switches, temlates and configs...
208
star
3

punchcard

[Deprecated] Laravel 11 comes with simliar solution out of the box
PHP
142
star
4

unused-public

Find Unused Public Elements in Your Code
PHP
137
star
5

type-coverage

PHPStan extension to require minimal type-coverage
PHP
132
star
6

phpstan-bodyscan

Get error count for each PHPStan level
PHP
121
star
7

awesome-php-ast

Awesome sources for amazing AST topic in world PHP
114
star
8

cognitive-complexity

PHPStan rules to measure cognitive complexity of your classes and methods
PHP
102
star
9

tomasvotruba.com

Read about upgrades, static analysis, GPT, Symfony and Laravel
PHP
88
star
10

class-leak

Find leaking classes that you never use... and get rid of them.
PHP
70
star
11

PhpStorm-LiveTemplates

Collection of Live Templates for PhpStorm
12
star
12

rector-composer-plugin

Detect Package Changes and run Rector Upgrade code after composer update
PHP
11
star
13

laracon-2024-rector-demo

Laracon talk for Amsterdam 2024 - Slides are here ↓
PHP
10
star
14

symfony-upgrade-demo-2022

PHP
9
star
15

phpunit-json-result

Print tests result in JSON in PHPUnit 10+ so other tools can use it
PHP
9
star
16

laravelize

Toolkit to help with your Symfony to Laravel migration
PHP
7
star
17

symfony-config-generator

Generate Symfony configs in CLI and use them for autocomplete
PHP
7
star
18

easystan

[WIP]
PHP
6
star
19

yaml-parser

AST for YAML
PHP
5
star
20

aws-sdk-php-symfony

Symfony 6/7+ bundle for Aws integration
PHP
5
star
21

shopsys-spryker-and-sylius-analysis

Static analysis of Shopsys, Sylius and Spryker
PHP
4
star
22

html-parser

Parse and traverse HTML using AST
PHP
3
star
23

rector-annotation-attributes-demo

PHP
3
star
24

editorconfig-fixer

PHP
3
star
25

laratyped

Bunch of PHPStan rules to make sure the Laravel project is clean, typed and reliable
PHP
3
star
26

symfony-legacy-controller-autowire

PHP
2
star
27

porto-01-meetup

PHP
2
star
28

torch

Smoke testing of TWIG templates
PHP
2
star
29

tomasvotruba

GitHub Profile repository :)
1
star
30

rector-syntax-bug

PHP
1
star
31

rector_parallel_test_ownci

PHP
1
star
32

rectoring.com

HTML
1
star
33

embedded-svg

Macro for embeding SVG into HTML. Preparing for Latte 3
PHP
1
star
34

rector-underscore-to-psr4

Test for https://github.com/rectorphp/rector/issues/7016
PHP
1
star
35

tryml

Trim your YAML files to minimum
PHP
1
star
36

mockistan

1
star