Download the PHP package camelot/doctrine-inheritance-mapping without Composer
On this page you can find all versions of the php package camelot/doctrine-inheritance-mapping. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download camelot/doctrine-inheritance-mapping
More information about camelot/doctrine-inheritance-mapping
Files in camelot/doctrine-inheritance-mapping
Package doctrine-inheritance-mapping
Short Description Doctrine inheritance mapping library
License MIT
Informations about the package doctrine-inheritance-mapping
Camelot Doctrine Inheritance Mapping
NOTE: For legacy PHP support (7.1+) please use the 1.0 branch.
Installation
Open a command console, enter your project directory and execute:
This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.
Standalone Configuration
Framework Configuration
Symfony Bundle
If using the Symfony Framework, you can enable the bundle by adding it to the
list of registered bundles in the config/bundles.php
file of your project:
Usage
Single Table Inheritance
@DiscriminatorMapItem
Annotation
Doctrine's Single Table Inheritance is an inheritance mapping strategy where all classes of a hierarchy are mapped to a single database table.
The mapping is handled by a "discriminator" column, defined in the mapping definition of the parent class. This column value defines the entity class to use, based on the inheritance hierarchy. This binds the parent to the children and mixes responsibilities in the process.
To separate these concerns, this library provides the @DiscriminatorMapItem
annotation for use in each entity in a hierarchy, replacing the parent class
use of Doctrine's @DiscriminatorMap
, thus eliminating the need to update the
parent for each subclass.
Example
Parent Class
NOTE: Using @DiscriminatorColumn
along with @DiscriminatorMapItem
is
optional, and has been omitted above for clarity.