Doctrine Mapping
For compatibility with entities built for Doctrine, Objectiphy can read some Doctrine attributes and annotations.
If any Objectiphy mapping values are not set, Objectiphy will use Doctrine's definitions instead. This is the case even if some attributes are supplied and others are not. For example, if you specify an Objectiphy Column
attribute or annotation with just a name
attribute, Objectiphy will also check the Doctrine attributes or annotations for information on data type and relationships. If you don't want it to do that, just specify all of the mapping definition values in the Objectiphy syntax (or set the column name to 'IGNORE' on the Objectiphy mapping definition to ignore the property completely).
Not all Doctrine attributes and annotations are supported or used by Objectiphy - only the following ones are processed:
ORM\Table
name: Name of the main table that stores information for this entity.
ORM\Column
name: Name of the column that stores data for this property.
type: Data type name.
ORM\Id
There are no values for this, but if present, it will be used to identify the primary key. This is the equivalent of
#[Objectiphy\Column(isPrimaryKey: true)]
(attribute) or@Objectiphy\Column(isPrimaryKey=true)
(annotation).
ORM\OrderBy
If specified, this just contains an array of properties on the child class to order by for one-to-many and many-to-many relationships, eg.
['name' => 'ASC', 'type' => 'DESC']
(attribute) or{"name"="ASC","type"="DESC"}
(annotation).
ORM\OneToOne
targetEntity: Class name of child entity. If not in the same namespace as the parent entity, it is best to fully qualify the class name.
mappedBy: Property of child class which owns the relationship, if applicable. Only necessary if the child owns the relationship (ie. the primary key of the table for the parent class is stored in a column on the table for the child class).
fetch: LAZY or EAGER
cascade: REMOVE or ALL Whether to delete child objects if the parent is deleted.
orphanRemoval: true or false Whether to delete child objects if they are removed from their parent.
ORM\ManyToOne
targetEntity: Class name of child entity.
mappedBy: Property of child class which owns the relationship, if applicable. Only necessary if the child owns the relationship (ie. the primary key of the table for the parent class is stored in a column on the table for the child class).
fetch: LAZY or EAGER
cascade: REMOVE or ALL Whether to delete child objects if the parent is deleted.
orphanRemoval: true or false Whether to delete child objects if they are removed from their parent.
ORM\OneToMany
targetEntity: Class name of child entity.
fetch: LAZY or EAGER
cascade: REMOVE or ALL Whether to delete child objects if the parent is deleted.
orphanRemoval: true or false Whether to delete child objects if they are removed from their parent.
ORM\ManyToMany
targetEntity: Class name of child entity.
cascade: REMOVE or ALL Whether to delete child objects if the parent is deleted.
orphanRemoval: true or false Whether to delete child objects if they are removed from their parent.
ORM\JoinColumn
name: Name of column on local table that holds the foreign key.
referencedColumnName: Name of column on target table that holds the key. Defaults to id if not specified.
ORM\Embedded
class: Fully qualified class name of the value object to embed.
columnPrefix: Prefix applied to all column names, or false if not using a prefix.
Last updated