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

https://github.com/chojnicki/php-enum-generator

Converts list to PHP enum.
https://github.com/chojnicki/php-enum-generator

enum enumerations php php8-features php81 vue vue3

Last synced: 2 months ago
JSON representation

Converts list to PHP enum.

Awesome Lists containing this project

README

        

# PHP Enum generator

Converts list (text with values separated by new lines) to [PHP enum](https://wiki.php.net/rfc/enumerations). You can choose between basic or int/string backed enumerations.

Live version: https://chojnicki.github.io/php-enum-generator

Just reminder - PHP support's native enums from version 8.1!

## Why?

I had to do a lot of enums. For something with couple of values it's not big of a problem, but imagine for example list of countries or currencies 😱 Of course typing this by hand would be too boring. So I decided to write simple Regex for this task, and one thing to another - ended up with this tiny simple app instead. Maybe it will help someone else too, cheers! 🥂

## Features

- Simple or backed enums
- Realtime generation
- Editable PHP file template with indent detection
- Names and values text transformations (uppercase/lowercase)
- Auto incrementation of backed integer values

## Usage and contribute

It's written using Vue, but there is no bundlers, depedencies etc. Just single `index.html` file to keep things simple.
So open this file in browser and you are ready to go, or edit it if you need to (PRs are welcomed).

License: MIT