mediagone / types-enums-doctrine
Provides Doctrine types for mediagone/types-enums package.
0.1.4
2022-02-14 16:12 UTC
Requires
- php: ^7.4|^8.0
- ext-json: *
- doctrine/dbal: ^2.7| ^3.0
- mediagone/types-enums: ^0.1
Requires (Dev)
- phpunit/phpunit: ^9.0
README
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.