mediagone/types-enums-doctrine

Provides Doctrine types for mediagone/types-enums package.

0.1.4 2022-02-14 16:12 UTC

This package is auto-updated.

Last update: 2024-11-14 22:14:34 UTC


README

Latest Version on Packagist Total Downloads Software License

Provides Doctrine types for "mediagone/types-enums" package.

Installation

This package requires PHP 7.4+ and Doctrine DBAL 2.7+

Add it as Composer dependency:

$ composer require mediagone/types-enums-doctrine

Configuration

This package provides a generic Doctrine type to remove the need to create a custom types for each enum class manually. Then, you only need to register your enums in the DoctrineEnumTypesLoader class, and custom types will be automatically created and registered for you.

With Symfony

If you're using this package in a Symfony project, register your enum classes in your app's kernel class:

use App\MyCustomEnum;
use App\MyOtherEnum;
use Symfony\Component\HttpKernel\Kernel as BaseKernel;

class Kernel extends BaseKernel
{
    use MicroKernelTrait;

    public function boot(): void
    {
        parent::boot();

        (new DoctrineEnumTypesLoader())->registerEnumTypes([
            MyCustomEnum::class,
            MyOtherEnum::class,
            // any other enum classes here
        ]);
    }

    ...
}

License

Types Enums for Doctrine is licensed under MIT license. See LICENSE file.