Download the PHP package enumeum/doctrine-enums-bundle without Composer
On this page you can find all versions of the php package enumeum/doctrine-enums-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download enumeum/doctrine-enums-bundle
More information about enumeum/doctrine-enums-bundle
Files in enumeum/doctrine-enums-bundle
Package doctrine-enums-bundle
Short Description Bundle for Doctrine enumerations extension for Postgres
License MIT
Informations about the package doctrine-enums-bundle
Doctrine Enums Bundle
Symfony bundle for Doctrine enums extension.
Requirements
Minimum PHP version is 8.1.
Installation
composer require enumeum/doctrine-enums-bundle
Bundle registration
If Symfony did not add bundle into ./config/bundles.php then do it manually.
Setup
Create doctrine_enum.yaml file under Symfony config folder. For single default connection setup is pretty easy
For multiple named connections config also supports them. Connections naming should be similar to Doctrine.
Types and Entities
Enumeum attribute for PHP enum:
- #[Enumeum\DoctrineEnum\Attribute\EnumType(name: 'type_name')] this attribute tells that this enum is database type. By default, it creates type in database with its own cases.
Enum setup
Entity setup
Please note that the configuration of the entity is no different from the usual one. Doctrine supports "enumType" property and converts it transparently.
Commands
In order to automate enums management bundle provides some commands.
Diff
Diff command will create migration file using Doctrine Migrations bundle config.
./bin/console enumeum:migrations:diff
List of options is generally similar to Doctrine's doctrine:migrations:diff command, except one additional option. "-U" allows to ignore enums already existing in database, otherwise diff command will try to drop them.
Schema validate
Schema validate command will check whether database enums are in sync with their definitions in application.
./bin/console enumeum:schema:validate
This command has optional "--em" and "--conn" options for those cases when application has different from "default" configuration.
Option "-U" allows to ignore enums already existing in database.
Integration with Doctrine's commands
Bundle also allows to use Enumeum commands with appropriate Doctrine's commands to perform better usability.
enumeum:migrations:diff -> doctrine:migrations:diff
enumeum:schema:validate -> doctrine:schema:validate
This is provided by Doctrine's commands overriding using commands decoration. Every Doctrine's command has additional option "-E" which allows to run Enumeum command before the general. Commands decoration is enabled by default and can be disabled by following configuration:
All versions of doctrine-enums-bundle with dependencies
doctrine/migrations Version ^3.2
doctrine/orm Version ^2.14
enumeum/doctrine-enums Version ^2.0
symfony/console Version ^4.4 || ^5.4 || ^6.0
symfony/dependency-injection Version ^4.4 || ^5.4 || ^6.0