You are browsing a version that is no longer maintained. |
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 through a Contrib Recipe therefore you need to allow its usage:
$ composer config extra.symfony.allow-contrib true
$ composer require doctrine/mongodb-odm-bundle
Install the bundle with Composer
To install DoctrineMongoDBBundle with Composer just run the following command:
$ composer require doctrine/mongodb-odm-bundle
All that is left to do is to update your AppKernel.php
file, and
register the new bundle:
Configuration
To get started, you'll need some basic configuration that sets up the document
manager. The easiest way is to enable auto_mapping
, which will activate
the MongoDB ODM across your application:
Of course, you'll also need to make sure that the MongoDB server is running in the background. For more details, see the MongoDB Quick Start guide. |
Authentication
If you use authentication on your MongoDB database you can the provide username,
password, and authentication database in the following way:
# app/config/parameters.yaml parameters: mongodb_server: mongodb://username:[email protected]:27017/?authSource=auth-db
The authentication database is different to the default database used by MongoDB. |