A robust and simple way to define enumerative in php using Doctrine 2 Types.
Scrutinizer | Code Quality | Latest | Development | PHP | License |
- PHP 7.0+
- [Robusto Enum] (https://github.com/jarddel/enum)
- DBAL
============= #### Can be used along with [DBAL](https://github.com/doctrine/dbal) (Database Abstraction Layer). To work on the concept of types: ============= A Simple Example: ```php class DayWeekEnum extends EnumType { const SUNDAY = 1, MONDAY = 2, TUESDAY = 3, WEDNESDAY = 4, THURSDAY = 5, FRIDAY = 6, SATURDAY = 7 ; } ```
Adding types to configurations:
doctrine:
dbal:
types:
day_week: DayweekEnum
Using types with annotation:
/** @Entity */
class Foo
{
/** @Column(type="integer") */
private $id;
/** @Column(type="day_week", name="day_week") */
private $day;
}
Using types with XML:
<entity name="Foo" table="foo">
<id name="id" column="id" type="integer" />
<field name="day" column="day_week" type="day_week" />
</entity>