An open API service indexing awesome lists of open source software.

https://github.com/genkiroid/enum-generator

Generate PHP class definition that extends Enum class from file(yaml, json).
https://github.com/genkiroid/enum-generator

cli enum php

Last synced: about 2 months ago
JSON representation

Generate PHP class definition that extends Enum class from file(yaml, json).

Awesome Lists containing this project

README

        

# Enum Generator

[![build](https://github.com/genkiroid/enum-generator/actions/workflows/ci.yml/badge.svg)](https://github.com/genkiroid/enum-generator/actions/workflows/ci.yml)

Generate PHP class definition that extends Enum class from file(yaml, json).

## Installation

```sh
composer require genkiroid/enum-generator
```

## Usage

Generate to STDOUT.

```sh
enum-generator --in enums.yaml
```

Generate to files. (Specify output dir.)

```sh
enum-generator --in enums.yaml --out /tmp/enums/
```

Generate to files. (Overwrite.)

```sh
enum-generator --in enums.yaml --out /tmp/enums/ --force
```

## Input file format

### YAML

```yaml
---
- User:
state:
active: 0
inactive: 1
- Shop:
state:
active: 0
inactive: 1
```

### JSON

```json
[
{
"User": {
"state": {
"active": 0,
"inactive": 1
}
}
},
{
"Shop": {
"state": {
"active": 0,
"inactive": 1
}
}
}
]
```

## Output

STDOUT.

```php