mattyeend/dynamic-enum-generator
最新稳定版本:v1.1.5
Composer 安装命令:
composer require mattyeend/dynamic-enum-generator
包简介
Automatically generate PHP enums from database columns in Laravel.
关键字:
README 文档
README
A Laravel package to automatically generate PHP enums from database columns.
Installation
composer require mattyeend/dynamic-enum-generator
This package supports Laravel 10, 11, and 12.
Laravel will auto-discover the service provider.
Usage
Generate an enum from a specific table and column:
php artisan enum:generate --table=users --column=status
Options
--table: The database table name.--column: The column name to generate the enum from.--path: Path where enums are saved (default:app/Enums).
Example
Suppose you have a users table with a status column containing:
activeinactivepending
Running:
php artisan enum:generate --table=users --column=status
Generates app/Enums/Status.php:
<?php namespace App\Enums; enum Status: string { case ACTIVE = 'active'; case INACTIVE = 'inactive'; case PENDING = 'pending'; }
Features
- Works with any table and column
- Creates directories automatically if missing
- Generates native PHP 8.1+ enums
- Perfect for status, role, type fields, etc.
License
This package is licensed under the MIT License.
Contributing
Feel free to fork the repository and submit pull requests for improvements or new features!
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-08-29