Im 'currently trying to integrate MongoDB with Doctrine in ZendFramework. I have done a lot of tutorials (in StackOverflow or elsewhere), but nothing really works.
I followed the tutorial step by step: http://www.bigwisu.com/2012/10/03/zend-framework-2-doctrine-odm and I got an error that I donβt understand.
Fatal error: Class 'MongoId' not found in /home/prooxi/www/zframework/vendor/doctrine/mongodb-odm/lib/Doctrine/ODM/MongoDB/Types/IdType.php on line 38
IdType.php is the source code for mongoDB, so the error should be somewhere else. Here are the files that I have. (Admin is the name of the module)
config / application.config.php
<?php
return array(
'modules' => array(
'Application',
'DoctrineModule',
'DoctrineMongoODMModule',
'Udmin',
'Listing',
'Admin',
),
'module_listener_options' => array(
'module_paths' => array(
'./module',
'./vendor',
),
'config_glob_paths' => array(
'config/autoload/{,*.}{global,local}.php',
),
),
);
configuration / startup / module.doctrine-mongo-odm.local.php
<?php
return array(
'doctrine' => array(
'connection' => array(
'odm_default' => array(
'server' => 'MYDBADRESS',
'port' => '27017',
'dbname' => 'px_boutique_test27',
'options' => array()
),
),
'configuration' => array(
'odm_default' => array(
'metadata_cache' => 'array',
'driver' => 'odm_default',
'generate_proxies' => true,
'proxy_dir' => 'data/DoctrineMongoODMModule/Proxy',
'proxy_namespace' => 'DoctrineMongoODMModule\Proxy',
'generate_hydrators' => true,
'hydrator_dir' => 'data/DoctrineMongoODMModule/Hydrator',
'hydrator_namespace' => 'DoctrineMongoODMModule\Hydrator',
'default_db' => 'test27',
'filters' => array(),
)
),
'driver' => array(
'odm_default' => array(
'drivers' => array(
'Admin\Document' => 'aplikasi'
)
),
'aplikasi' => array(
'class' => 'Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver',
'cache' => 'array',
'paths' => array(
'module/Admin/src/Admin/Document'
)
)
),
'documentmanager' => array(
'odm_default' => array(
'connection' => 'odm_default',
'configuration' => 'odm_default',
'eventmanager' => 'odm_default'
)
),
'eventmanager' => array(
'odm_default' => array(
'subscribers' => array()
)
),
),
);
Module / Admin / Src / Admin / Controller / AdminController.php
<?php
namespace Admin\Controller;
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
use Mongo;
use Zend\Session\SaveHandler\MongoDB;
use Zend\Session\SaveHandler\MongoDBOptions;
use Zend\Session\SessionManager;
use Admin\Document\Boutique;
class AdminController extends AbstractActionController
{
public function indexAction()
{
$dm = $this->getServiceLocator()->get('doctrine.documentmanager.odm_default');
$b = new Boutique();
$dm->find('Admin\Document\Boutique', '52e6c677362dca7fcd40ab09');
}
}
Module / admin / config / module.config.php
<?php
return array(
'controllers' => array(
'invokables' => array(
'Admin\Controller\Admin' => 'Admin\Controller\AdminController',
),
),
'router' => array(
'routes' => array(
'admin' => array(
'type' => 'segment',
'options' => array(
'route' => '/admin[/][:action][/:id]',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]+',
),
'defaults' => array(
'controller' => 'Admin\Controller\Admin',
'action' => 'index',
),
),
),
),
),
'view_manager' => array(
'template_path_stack' => array(
'admin' => __DIR__ . '/../view',
),
),
);
MongoDB .
!