PHPackages                             haakco/laravel-enum-generator - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. haakco/laravel-enum-generator

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

haakco/laravel-enum-generator
=============================

Generates simple class to act as an enum from a table specified in its con

v6.0.1(3mo ago)010.9kmitPHPPHP ^8.4CI failing

Since Jan 24Pushed 1mo ago2 watchersCompare

[ Source](https://github.com/haakco/laravel-enum-generator)[ Packagist](https://packagist.org/packages/haakco/laravel-enum-generator)[ Docs](https://github.com/haakco/laravel-enum-generator)[ RSS](/packages/haakco-laravel-enum-generator/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (13)Versions (39)Used By (0)

LaravelEnumGenerator
====================

[](#laravelenumgenerator)

[![Latest Version on Packagist](https://camo.githubusercontent.com/db99230eaec6535eec6428e35fc5408c72d762d4edea79c1529860d77708f15b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6861616b636f2f6c61726176656c2d656e756d2d67656e657261746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/haakco/laravel-enum-generator)[![Total Downloads](https://camo.githubusercontent.com/d316163b16bca1889a9809c9fd2a02388004344b936f90267b1462f2f24e8366/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6861616b636f2f6c61726176656c2d656e756d2d67656e657261746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/haakco/laravel-enum-generator)[![Build Status](https://camo.githubusercontent.com/d70cdeb86c636f62ff4b8f7bafe4a5350dabf67ab889c7267d3bf97af2a25704/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6861616b636f2f6c61726176656c2d656e756d2d67656e657261746f722f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/haakco/laravel-enum-generator)[![StyleCI](https://camo.githubusercontent.com/cb13a877afd1dbe223c631789c3f922d3ace958fdb334a9cce9b26afefbc2ebd/68747470733a2f2f7374796c6563692e696f2f7265706f732f31323334353637382f736869656c64)](https://styleci.io/repos/12345678)

This is where your description should go. Take a look at [contributing.md](contributing.md) to see a to do list.

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

[](#installation)

Via Composer

```
$ composer require haakco/laravel-enum-generator --dev
```

### Configuration for local environment only

[](#configuration-for-local-environment-only)

If you wish to enable generators only for your local environment, you should install it via composer using the --dev option like this:

```
composer require haakco/laravel-enum-generator --dev
```

Then you'll need to register the provider in `app/Providers/AppServiceProvider.php` file.

```
public function register()
{
    if ($this->app->environment() == 'local') {
        $this->app->register(\HaakCo\LaravelEnumGenerator\LaravelEnumGeneratorServiceProvider::class);
    }
}
```

Usage
-----

[](#usage)

Copy the config over

```
php artisan vendor:publish --provider="HaakCo\LaravelEnumGenerator\LaravelEnumGeneratorServiceProvider"
```

Edit the config file enum-generator.php to specify which tables to use to generate the files.

Now run the following to re-create your models.

```
php artisan modelEnum:create
```

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

[](#configuration)

The `config/enum-generator.php` file supports the following options:

### Global Options

[](#global-options)

OptionDefaultDescription`use-enum-format``true`Use PHP 8.1+ enum format (vs legacy class constants)`default-leave-schema``false`Include schema name in generated class name`default-uuid``false`Include UUID field in generated enums`id-field``'id'`Default column name for enum values`name-field``'name'`Default column name for enum case names`default-prepend_class``''`Prefix for generated class names`default-prepend_name``''`Prefix for generated enum case names`enumPath``app_path() . '/Models/Enums'`Output directory for generated files`default-order-by``['name', 'id']`Default ordering for enum cases### Per-Table Options

[](#per-table-options)

Each table in the `tables` array can have these options:

```
'tables' => [
    'public.statuses' => [
        'uuid' => false,
        'leave-schema' => true,
        'prepend-class' => 'App',
        'prepend-name' => 'Status',
        'id-field' => 'id',
        'name-field' => 'name',
        'order-by' => ['name' => 'asc'],
        'where' => [
            'is_active' => true,
            'type' => 'public',
        ],
    ],
],
```

### Filtering Rows with `where`

[](#filtering-rows-with-where)

Use the `where` option to filter which database rows become enum cases. This is useful when:

- You have duplicate values and need to filter by another column
- You only want active/enabled records
- You need to limit enums to a specific type or category

```
'tables' => [
    // Only generate enums for active permissions
    'permissions' => [
        'where' => [
            'is_active' => true,
        ],
    ],

    // Only generate enums where type equals 'system'
    'categories' => [
        'where' => [
            'type' => 'system',
            'deleted_at' => null,
        ],
    ],
],
```

The `where` option accepts an associative array where keys are column names and values are matched with equality (`=`). Multiple conditions are combined with `AND`.

Change log
----------

[](#change-log)

Please see the [changelog](changelog.md) for more information on what has changed recently.

Testing
-------

[](#testing)

```
$ composer test
```

Contributing
------------

[](#contributing)

Please see [contributing.md](contributing.md) for details and a todolist.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Tim Haak](https://github.com/haakco)
- [All Contributors](../../contributors)

License
-------

[](#license)

mit. Please see the [license file](license.md) for more information.

###  Health Score

55

—

FairBetter than 98% of packages

Maintenance84

Actively maintained with recent releases

Popularity23

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity86

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 87% 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 ~64 days

Recently: every ~188 days

Total

35

Last Release

114d ago

Major Versions

v1.2.0 → v2.0.02020-11-08

v2.0.8 → v3.0.02021-01-06

v3.0.6 → v4.0.72023-02-12

v4.0.16 → v5.0.12024-01-03

v5.1.1 → v6.0.02025-11-03

PHP version history (6 changes)v1.0.0PHP &gt;=7.3.0

v1.0.3PHP &gt;=7.1.0

v3.0.6PHP &gt;=8.0.0

v5.0.1PHP &gt;=8.3.0

v5.1.1PHP &gt;=8.0

v6.0.0PHP ^8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/e15a429a90f3adbe239550525faa6cf2d2d32b9bd8add3a97255f9dacabee805?d=identicon)[haakco](/maintainers/haakco)

---

Top Contributors

[![timhaak](https://avatars.githubusercontent.com/u/271607?v=4)](https://github.com/timhaak "timhaak (80 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (12 commits)")

---

Tags

laravelmodelLaravelEnumGeneratorhaakcolaravel-enum-generator

###  Code Quality

TestsPHPUnit

Code StyleECS

### Embed Badge

![Health badge](/badges/haakco-laravel-enum-generator/health.svg)

```
[![Health](https://phpackages.com/badges/haakco-laravel-enum-generator/health.svg)](https://phpackages.com/packages/haakco-laravel-enum-generator)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[tucker-eric/eloquentfilter

An Eloquent way to filter Eloquent Models

1.8k4.8M26](/packages/tucker-eric-eloquentfilter)[spatie/laravel-enum

Laravel Enum support

3655.4M31](/packages/spatie-laravel-enum)[zonneplan/laravel-module-loader

Module loader for Laravel

24118.4k](/packages/zonneplan-laravel-module-loader)[tehwave/laravel-achievements

Simple, elegant Achievements the Laravel way

7012.8k](/packages/tehwave-laravel-achievements)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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