PHPackages                             y-tsuzaki/php-enum-spy - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [CLI &amp; Console](/categories/cli)
4. /
5. y-tsuzaki/php-enum-spy

ActiveLibrary[CLI &amp; Console](/categories/cli)

y-tsuzaki/php-enum-spy
======================

A CLI tool to extract a list of Enum definitions from PHP files.

v0.1.2(1y ago)213[2 issues](https://github.com/y-tsuzaki/php-enum-spy/issues)MITPHPPHP ^8.1

Since Nov 5Pushed 1y ago1 watchersCompare

[ Source](https://github.com/y-tsuzaki/php-enum-spy)[ Packagist](https://packagist.org/packages/y-tsuzaki/php-enum-spy)[ RSS](/packages/y-tsuzaki-php-enum-spy/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (2)Versions (6)Used By (0)

PHP-Enum-Spy
============

[](#php-enum-spy)

A PHP CLI tool for extracting Enum definitions. Outputs Enum definitions to CSV and JSON files for easy access and analysis.

Example
-------

[](#example)

This tool can output JSON files like the following.

```
{
    "enums": {
        "YTsuzaki\\PhpEnumSpyExample\\ExampleEnum": {
            "className": "ExampleEnum",
            "namespace": "YTsuzaki\\PhpEnumSpyExample",
            "fully_qualified_class_name": "YTsuzaki\\PhpEnumSpyExample\\ExampleEnum",
            "filePath": "/Users/y-tsuzaki/work/php-enum-spy-example/src/ExampleEnum.php",
            "cases": {
                "IN_PROGRESS": {
                    "name": "IN_PROGRESS",
                    "value": "in_progress",
                    "displayName": "進行中"
                },
                "PUNIRU": {
                    "name": "PUNIRU",
                    "value": "puniru_is_cute_slime",
                    "displayName": "ぷにるはかわいいスライム"
                }
            }
        }
    }
}
```

CSV files are output in the following format.

[![CSV_FILE_SCREENSHOT](https://private-user-images.githubusercontent.com/26266190/383628024-fbbf926d-2943-4e6e-ad64-3e97df91d22f.png?jwt=eyJ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1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNjA2MjIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjYwNjIyVDEzMTE0MVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWEzMTZmZThiNjZmZDc3MWQ2OGQ2OWZjMmY1ZTEyZDQ2NThjZGQxMTU5NTI4ZjM2MTc0ZThjMDViMGQ1MDc1MTMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JnJlc3BvbnNlLWNvbnRlbnQtdHlwZT1pbWFnZSUyRnBuZyJ9.qs_1CCCjpf--2siBjVlk_q-voI0RfTq6hz5Mtia5_qw)

```
class_name,file_path,case,value,displayName
"YTsuzaki\PhpEnumSpyExample\ExampleEnum",/Users/y-tsuzaki/work/php-enum-spy-example/src/ExampleEnum.php,IN_PROGRESS,in_progress,進行中
"YTsuzaki\PhpEnumSpyExample\ExampleEnum",/Users/y-tsuzaki/work/php-enum-spy-example/src/ExampleEnum.php,PUNIRU,puniru_is_cute_slime,ぷにるはかわいいスライム
```

The Enum class used in the sample is as follows.

```
 '未完了',
            self::IN_PROGRESS => '進行中',
            self::DONE => '完了',
            self::PUNIRU => 'ぷにるはかわいいスライム',
        };
    }
}
```

Please refer to the following Example repository for details.

Configuration
-------------

[](#configuration)

Create a configuration file `php-enum-spy.config.php` in the root directory of your project.

```
 [
    // Add the directory where the Enum class file is located
    "src",
  ],
  "convert_functions" => [],
];

return $config;
```

### Custom conversion function

[](#custom-conversion-function)

If you want to read the method in Enum and convert the value, add a custom conversion function as follows.

```
 [
    // Add the directory where the Enum class file is located
    "src",
  ],
  "convert_functions" => [
      // Add your custom convert function if needed
      "your_custom_function" => function (UnitEnum $enum) {
          if (method_exists($enum, 'toJapanese')) {
              return $enum->toJapanese();
          }
          return null;
      },
  ],
];

return $config;
```

Installation
------------

[](#installation)

```
composer require --dev y-tsuzaki/php-enum-spy
```

Usage
-----

[](#usage)

Create a configuration file (php-enum-spy.config.php) based on the above description.

```
vi php-enum-spy.config.php
```

Run the following command.

```
vendor/bin/php-enum-spy
```

CSV files and JSON files are output to ./output.

```
output
├── enum_metadata.csv
└── enum_metadata.json

```

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance15

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

5

Last Release

603d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/26266190?v=4)[y-tsuzaki](/maintainers/y-tsuzaki)[@y-tsuzaki](https://github.com/y-tsuzaki)

---

Top Contributors

[![y-tsuzaki](https://avatars.githubusercontent.com/u/26266190?v=4)](https://github.com/y-tsuzaki "y-tsuzaki (20 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/y-tsuzaki-php-enum-spy/health.svg)

```
[![Health](https://phpackages.com/badges/y-tsuzaki-php-enum-spy/health.svg)](https://phpackages.com/packages/y-tsuzaki-php-enum-spy)
```

###  Alternatives

[duncan3dc/console

Create command line php applications using symfony/console

16263.5k2](/packages/duncan3dc-console)[getkirby/cli

Kirby command line interface

6581.6k42](/packages/getkirby-cli)[shopware/psh

A build tool written in PHP utilizing sh scripts

6131.7k](/packages/shopware-psh)[soy-php/soy

PHP task runner focused on clean syntax and allowing flexible implementation

6612.1k10](/packages/soy-php-soy)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
