User Guide
Installation of this module uses composer. For composer documentation, please refer to getcomposer.org.
$ composer require doctrine/doctrine-orm-module
Then add DoctrineModule
and DoctrineORMModule
to your
config/application.config.php
and create directory
data/DoctrineORMModule/Proxy
and make sure your application has
write access to it.
Installation without composer is not officially supported and requires
you to manually install all dependencies that are listed in
composer.json
Entities settings
To register your entities with the ORM, add following metadata driver configurations to your module (merged) configuration for each of your entities namespaces:
1 <?php
return [
'doctrine' => [
'driver' => [
// defines an annotation driver with two paths, and names it `my_annotation_driver`
'my_annotation_driver' => [
'class' => \Doctrine\ORM\Mapping\Driver\AnnotationDriver::class,
'cache' => 'array',
'paths' => [
'path/to/my/entities',
'another/path',
],
],
// default metadata driver, aggregates all other drivers into a single one.
// Override `orm_default` only if you know what you're doing
'orm_default' => [
'drivers' => [
// register `my_annotation_driver` for any entity under namespace `My\Namespace`
'My\Namespace' => 'my_annotation_driver',
],
],
],
],
];
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
Connection settings
Connection parameters can be defined in the application configuration:
1 <?php
return [
'doctrine' => [
'connection' => [
// default connection name
'orm_default' => [
'driverClass' => \Doctrine\DBAL\Driver\PDO\MySQL\Driver::class,
'params' => [
'host' => 'localhost',
'port' => '3306',
'user' => 'username',
'password' => 'password',
'dbname' => 'database',
],
],
],
],
];
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Full configuration options
An exhaustive list of configuration options can be found directly in the Options classes of each module.
You can find documentation about the module’s features at the following links:
Registered Service names
doctrine.connection.orm_default
: aDoctrine\DBAL\Connection
instancedoctrine.configuration.orm_default
: aDoctrine\ORM\Configuration
instancedoctrine.driver.orm_default
: default mapping driver instancedoctrine.entitymanager.orm_default
: theDoctrine\ORM\EntityManager
instanceDoctrine\ORM\EntityManager
: an alias ofdoctrine.entitymanager.orm_default
doctrine.eventmanager.orm_default
: theDoctrine\Common\EventManager
instance