Tag: doctrine

Using MySQL Enums in Symfony Doctrine

Enum isn’t supported in Doctrine. I prefer to keep things as vanilla as possible so instead of registering a new type, we shall map it to a varchar.

You have to ensure that each varchar field that is an “enum” in the database only gets passed the allowed values. You can easily enforce this in your entities:

This is a lot easier to manage and requires no migration if you decide to add more options.

source: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/cookbook/mysql-enums.html