Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7865559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T00:07:36+00:00 2026-06-03T00:07:36+00:00

I am trying to integrate zf2 beta3 with doctrine mongo odm (https://github.com/doctrine/DoctrineMongoODMModule) but no

  • 0

I am trying to integrate zf2 beta3 with doctrine mongo odm (https://github.com/doctrine/DoctrineMongoODMModule) but no sucess.

How can I install and configure it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T00:07:38+00:00Added an answer on June 3, 2026 at 12:07 am

    I will give the steps I have done to integrate zf2 with mongodb doctrine odm

    1.Download the mongodb doctrine odm module and place in vendor directory or clone it from github

    cd /path/to/project/vendor
    git clone --recursive https://github.com/doctrine/DoctrineMongoODMModule.git
    

    2.Copy the file from /path/to/project/vendor/DoctrineMongoODMModule/config/module.doctrine_mongodb.config.php.dist, place in your path/to/your/project/config/autoload/ and rename to module.doctrine_mongodb.local.config.php

    3.Edit your module.doctrine_mongodb.local.config.php.
    Change the default db

    'config' => array(
        // set the default database to use (or not)
        'default_db' => 'myDbName'
    ), 
    

    Change your connection params

    'connection' => array(
        //'server'  => 'mongodb://<user>:<password>@<server>:<port>',
        'server'  => 'mongodb://localhost:27017',
        'options' => array()
    ),
    

    Change the driver options

    'driver' => array(
        'class'     => 'Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver',
        'namespace' => 'Application\Document',
        'paths'     => array('module/Application/src/Application/Document'),
    ),
    

    Add proxy and hydratros config

            'mongo_config' => array(
                'parameters' => array(
                    'opts' => array(
                        'auto_generate_proxies'   => true,
                        'proxy_dir'               => __DIR__ . '/../../module/Application/src/Application/Document/Proxy',
                        'proxy_namespace'         => 'Application\Model\Proxy',
                        'auto_generate_hydrators' => true,
                        'hydrator_dir'            => __DIR__ . '/../../module/Application/src/Application/Document/Hydrators',
                        'hydrator_namespace'      => 'Application\Document\Hydrators',
                        'default_db' => $settings['config']['default_db'],
                    ),
                    'metadataCache' => $settings['cache'],
                )
            ),
    

    4.Create a directory named “Document” in /path/to/project/module/Application/src/Application/ where goes your documents mapping and inside “Document” directory, create “Proxy” and “Hydrators” directories.

    5.Edit your /path/to/project/config/application.config.php and add ‘DoctrineMongoODMModule’ to modules array

    6.Be sure you have mongo php extension installed otherwise download at http://www.php.net/manual/en/mongo.installation.php#mongo.installation.windows and copy it to your extension php directory, usually /php/ext. Add the extension line acording the name file extension you have downloaded “extension=php_mongo-x.x.x-5.x-vc9.dll” in your php.ini.

    7.Create a document mapping User.php in your document directory application module.

    <?php
    namespace Application\Document;
    use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
    /** @ODM\Document */
    class User
    {
        /** @ODM\Id */
        private $id;
    
        /** @ODM\Field(type="string") */
        private $name;
    
        /**
         * @return the $id
         */
        public function getId() {
            return $this->id;
        }
    
        /**
         * @return the $name
         */
        public function getName() {
            return $this->name;
        }
    
        /**
         * @param field_type $id
         */
        public function setId($id) {
            $this->id = $id;
        }
    
        /**
         * @param field_type $name
         */
        public function setName($name) {
            $this->name = $name;
        }
    
    }
    

    8.Persist it, for example in your controller

    <?php
    
    namespace Application\Controller;
    
    use Zend\Mvc\Controller\ActionController,
        Zend\View\Model\ViewModel,
        Application\Document\User;
    
    class IndexController extends ActionController
    {
    
        public function indexAction()
        {
            $dm = $this->getLocator()->get('mongo_dm');
    
            $user = new User();
            $user->setName('Bulat S.');
    
            $dm->persist($user);
            $dm->flush();
    
            return new ViewModel();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to integrate rspec_api_documentation (https://github.com/zipmark/rspec_api_documentation) into my sinatra app. I'm running into the
I am trying to integrate Neil's search plugin http://www.neilcrookes.com/2009/11/21/cakephp-searchable-plugin to my application but I
I'm trying to integrate passport into my nodejs server using connect, but can't seem
I'm trying to integrate the Google Federated Login with a premier apps account, but
I'm trying integrate spring with hibernate but catch exception on project start. Caused by:
I'm trying integrate spring with hibernate but catch NamingException: Context is read only stacktrace
I'm trying to integrate facebook login on a site I'm working on, but so
I am trying to integrate isotope but Iam having problems getting it to work
I am trying to integrate the TestFlight iOS SDK into my Forge app. Can't
I'm trying to integrate Django's comment app into my site but with no success.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.