developer-samuel/php-codestats

A high-performance, strictly typed CLI tool for fast source code volume metrics (files, lines, and characters).

Maintainers

Package info

github.com/Developer-Samuel/php-codestats

pkg:composer/developer-samuel/php-codestats

Statistics

Installs: 6

Dependents: 0

Suggesters: 0

Stars: 1

Open Issues: 0

1.1.0 2026-03-16 18:31 UTC

This package is auto-updated.

Last update: 2026-04-16 18:41:29 UTC


README

Command-line tool for analyzing source code metrics: files, lines, and characters.

Installation

Install as a development dependency via Composer:

composer require --dev developer-samuel/php-codestats

Configuration

A configuration file codestats-analyzer.xml is required in the project root. It defines:

  • file_extensions - file types to include.
  • ignored_dirs - directories to skip.

You can bootstrap it automatically from the library:

php -r "require 'vendor/autoload.php'; DeveloperSamuel\PhpCodeStats\Installer::copyConfig();"

Or copy it manually from vendor/developer-samuel/php-codestats/config/analyzer.xml to your project root.

Example codestats-analyzer.xml

<?xml version="1.0" encoding="UTF-8"?>
<analyzer>
    <file_extensions>
        <ext>php</ext>
        <ext>js</ext>
        <ext>css</ext>
    </file_extensions>
    <ignored_dirs>
        <dir>bin</dir>
        <dir>vendor</dir>
        <dir>node_modules</dir>
        <dir>public</dir>
    </ignored_dirs>
</analyzer>

Usage

Three commands are available:

# Count stats
php vendor/bin/count-stats

# Count files
php vendor/bin/count-files

# Count lines
php vendor/bin/count-lines

# Count characters
php vendor/bin/count-chars

Commands automatically use the codestats-analyzer.xml in your project root.

Notes

  • The config file can be edited to add/remove extensions or ignored directories.
  • Using php -r "Installer::copyConfig();" is enough to bootstrap the default config. No need to write manually unless you want custom changes.
  • Ideal for integrating into CI/CD or dev workflow to monitor project metrics.