You are browsing a version that has not yet been released. |
Installation
This chapter assumes you have Composer installed globally, as explained in the installation chapter of the Composer documentation.
The ODM requires the MongoDB driver ( |
Install the bundle with Symfony Flex
A Flex recipe for the DoctrineMongoDBBundle is provided as a Contrib Recipe. You need to allow its usage first:
$ composer config extra.symfony.allow-contrib true
$ composer require doctrine/mongodb-odm-bundle
Install the bundle with Composer
To install DoctrineMongoDBBundle with Composer run the following command:
$ composer require doctrine/mongodb-odm-bundle
Enable the Bundle
The bundle should be automatically enabled if you use Flex.
Otherwise, you'll need to manually enable the bundle by adding the
following line in the config/bundles.php
file of your project:
Configuration
Flex recipe will automatically create the config/packages/doctrine_mongodb.yaml
file with default configuration. Without Flex you need to create the file
manually and fill it with some basic configuration that sets up the document manager.
The recommended way is to enable auto_mapping
, which will activate
the MongoDB ODM across your application:
Please also make sure that the MongoDB server is running in the background. For more details, see the MongoDB Installation Tutorials. |
You can configure bundle options that depend on where your application is run (e.g. during tests or development) with Environment Variables. |
Authentication
If you use authentication on your MongoDB database, then you can provide username, password, and authentication database in the following way:
The authentication database is different from the default database used by MongoDB. |