Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

229 lines (162 sloc) 5.173 kb

Embedded Mapping

This chapter explains how embedded documents are mapped in Doctrine.

Embed One

Embed a single document:

Embed Many

Embed many documents:

Mixing Document Types

If you want to store different types of embedded documents in the same field, you can simply omit the targetDocument option:

Now the $tasks property can store any type of document! The class name will be automatically stored in a field named _doctrine_class_name within the embedded document. The field name can be customized with the discriminatorField option:

You can also specify a discriminator map to avoid storing the fully qualified class name in each embedded document:

Cascading Operations

All operations on embedded documents are automatically cascaded. This is because embedded documents are part of their parent document and cannot exist without those by nature.

Jump to Line
Something went wrong with that request. Please try again.