PHPackages                             illuminatech/enum-seeder - 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. [Database &amp; ORM](/categories/database)
4. /
5. illuminatech/enum-seeder

ActiveLibrary[Database &amp; ORM](/categories/database)

illuminatech/enum-seeder
========================

Allows easy creation of DB seeders for the dictionary (enum) type tables

1.0.5(1mo ago)31.8k↓33.3%BSD-3-ClausePHPCI passing

Since Jun 3Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/illuminatech/enum-seeder)[ Packagist](https://packagist.org/packages/illuminatech/enum-seeder)[ GitHub Sponsors](https://github.com/klimov-paul)[ Patreon](https://www.patreon.com/klimov_paul)[ RSS](/packages/illuminatech-enum-seeder/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (6)Versions (7)Used By (0)

 [ ![](https://avatars1.githubusercontent.com/u/47185924) ](https://github.com/illuminatech)

Laravel Enum Seeder
===================

[](#laravel-enum-seeder)

This extension allows easy creation of DB seeders for the dictionary (enum) type tables, such as statuses, types, categories and so on.

For license information check the [LICENSE](LICENSE.md)-file.

[![Latest Stable Version](https://camo.githubusercontent.com/e4beec78dd7665ac1da7bb679932f017d0e7c5cac164d3efe101ab3a5a1e2da8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f696c6c756d696e61746563682f656e756d2d7365656465722e737667)](https://packagist.org/packages/illuminatech/enum-seeder)[![Total Downloads](https://camo.githubusercontent.com/5b75f0b66cc41b6cb8720fc7ada635b635e84b8a84ef5e3f6be862261a1fdbc4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f696c6c756d696e61746563682f656e756d2d7365656465722e737667)](https://packagist.org/packages/illuminatech/enum-seeder)[![Build Status](https://github.com/illuminatech/enum-seeder/workflows/build/badge.svg)](https://github.com/illuminatech/enum-seeder/actions)

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

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require --prefer-dist illuminatech/enum-seeder

```

or add

```
"illuminatech/enum-seeder": "*"
```

to the "require" section of your composer.json.

Usage
-----

[](#usage)

Almost every project requires specification of so called 'dictionary' or 'enum' entities, such as statuses, types, categories and so on. It is not always practical to keep such data as [PHP enums](https://www.php.net/manual/en/language.enumerations.php)or [class-base enums](https://github.com/myclabs/php-enum). Sometimes it has to be put into a database table. For example: when we need to provide ability for the system administrator to edit human-readable title or description of the particular category or status, or enable/disable particular records, or simply to keep the database integrity.

Obviously keeping dictionary (enum) in the database tables creates a problem of its synchronization. As our project evolves new categories and statuses may appear, and some may become obsolete. Thus, we need a tool, which allows updating of the data in the dictionary (enum) tables. This package provides such a tool.

The idea is in creation of the special kind of database seeder, which synchronizes particular enum table with the predefined data in the way, it could be invoked multiple times without creation of redundant records or breaking an integrity. You can create such seeder extending `Illuminatech\EnumSeeder\EnumSeeder`. For example:

```
