DoctrineBundle supports all parameters that default Doctrine drivers
accept, converted to the XML or YAML naming standards that Symfony
enforces. See the Doctrine DBAL documentation for more information.
The following block shows all possible configuration keys:

doctrine:dbal:dbname:databasehost:localhostport:1234user:userpassword:secretdriver:pdo_mysql# if the url option is specified, it will override the above configurl:mysql://db_user:[email protected]:3306/db_name# the DBAL driverClass optiondriver_class:App\DBAL\MyDatabaseDriver# the DBAL driverOptions optionoptions:foo:barpath:'%kernel.project_dir%/var/data/data.sqlite'memory:trueunix_socket:/tmp/mysql.sock# the DBAL wrapperClass optionwrapper_class:App\DBAL\MyConnectionWrappercharset:UTF8logging:'%kernel.debug%'platform_service:App\DBAL\MyDatabasePlatformServiceserver_version:'5.6'mapping_types:enum:stringtypes:custom:App\DBAL\MyCustomType

The server_version option was added in Doctrine DBAL 2.5, which
is used by DoctrineBundle 1.3. The value of this option should match
your database server version (use postgres -V or psql -V command
to find your PostgreSQL version and mysql -V to get your MySQL
version).

If you are running a MariaDB database, you must prefix the server_version
value with mariadb- (e.g. server_version: mariadb-10.2.12).

Always wrap the server version number with quotes to parse it as a string
instead of a float number. Otherwise, the floating-point representation
issues can make your version be considered a different number (e.g. 5.6
will be rounded as 5.5999999999999996447286321199499070644378662109375).

If you don't define this option and you haven't created your database
yet, you may get PDOException errors because Doctrine will try to
guess the database server version automatically and none is available.

If you want to configure multiple connections in YAML, put them under the
connections key and give them a unique name:

The database_connection service always refers to the default connection,
which is the first one defined or the one configured via the
default_connection parameter.

Each connection is also accessible via the doctrine.dbal.[name]_connection
service where [name] is the name of the connection. In a controller
extending AbstractController, you can access it directly using the
getConnection() method and the name of the connection:

$connection=$this->getDoctrine()->getConnection('customer');$result=$connection->fetchAll('SELECT name FROM customer');

This following configuration example shows all the configuration defaults
that the ORM resolves to:

1
2
3
4
5
6
7
8
9
10
11

doctrine:orm:auto_mapping:true# the standard distribution overrides this to be true in debug, false otherwiseauto_generate_proxy_classes:falseproxy_namespace:Proxiesproxy_dir:'%kernel.cache_dir%/doctrine/orm/Proxies'default_entity_manager:defaultmetadata_cache_driver:arrayquery_cache_driver:arrayresult_cache_driver:array

There are lots of other configuration options that you can use to overwrite
certain classes, but those are for very advanced use-cases only.

# config/packages/prod/doctrine.yamlframework:cache:pools:doctrine.result_cache_pool:adapter:cache.appdoctrine.system_cache_pool:adapter:cache.systemdoctrine:orm:# ...metadata_cache_driver:type:poolpool:doctrine.system_cache_poolquery_cache_driver:type:poolpool:doctrine.system_cache_poolresult_cache_driver:type:poolpool:doctrine.result_cache_pool# in addition to Symfony Cache pools, you can also use the# 'type: service' option to use any service as the cachequery_cache_driver:type:serviceid:App\ORM\MyCacheService

Explicit definition of all the mapped entities is the only necessary
configuration for the ORM and there are several configuration options that
you can control. The following configuration options exist for a mapping:

A common namespace prefix that all entities of this mapping share. This prefix
should never conflict with prefixes of other defined mappings otherwise some of
your entities cannot be found by Doctrine.

Doctrine's auto_mapping feature loads annotation configuration from
the Entity/ directory of each bundle and looks for other formats (e.g.
YAML, XML) in the Resources/config/doctrine directory.

If you store metadata somewhere else in your bundle, you can define your
own mappings, where you tell Doctrine exactly where to look, along with
some other configurations.

If you're using the auto_mapping configuration, you just need to overwrite
the configurations you want. In this case it's important that the key of
the mapping configurations corresponds to the name of the bundle.

For example, suppose you decide to store your XML configuration for
AppBundle entities in the @AppBundle/SomeResources/config/doctrine
directory instead:

If the type on the bundle configuration isn't set, the DoctrineBundle
will try to detect the correct mapping configuration format for the bundle.

DoctrineBundle will look for files matching *.orm.[FORMAT] (e.g.
Post.orm.yaml) in the configured dir of your mapping (if you're mapping
a bundle, then dir is relative to the bundle's directory).

The bundle looks for (in this order) XML, YAML and PHP files.
Using the auto_mapping feature, every bundle can have only one
configuration format. The bundle will stop as soon as it locates one.

If it wasn't possible to determine a configuration format for a bundle,
the DoctrineBundle will check if there is an Entity folder in the bundle's
root directory. If the folder exist, Doctrine will fall back to using an
annotation driver.

If dir is not specified, then its default value depends on which configuration
driver is being used. For drivers that rely on the PHP files (annotation,
staticphp) it will be [Bundle]/Entity. For drivers that are using
configuration files (XML, YAML, ...) it will be
[Bundle]/Resources/config/doctrine.

If the dir configuration is set and the is_bundle configuration
is true, the DoctrineBundle will prefix the dir configuration with
the path of the bundle.