定制 mattyeend/dynamic-enum-generator 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mattyeend/dynamic-enum-generator

最新稳定版本:v1.1.6

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:

  • active
  • inactive
  • pending

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
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-08-29