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 (mongodb).

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:

1// app/AppKernel.php public function registerBundles() { $bundles = array( // ... new Doctrine\Bundle\MongoDBBundle\DoctrineMongoDBBundle(), ); // ... }
2
3
4
5
6
7
8
9
10

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:

1# app/config/parameters.yml parameters: mongodb_server: "mongodb://localhost:27017"
2
3
1# app/config/config.yml doctrine_mongodb: connections: default: server: "%mongodb_server%" options: {} default_database: test_database document_managers: default: auto_mapping: true
2
3
4
5
6
7
8
9
10

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.