I am trying to install the MongoDB bundle into Symfony2. I followed Symfony documentation.
My config.yml file is:
doctrine_mongodb:
connections:
default:
server: mongodb://localhost:27017
options: {}
default_database: test_database
document_managers:
default:
auto_mapping: true
My autoload file is:
use Doctrine\Common\Annotations\AnnotationRegistry;
use Composer\Autoload\ClassLoader;
$loader = require __DIR__.'/../vendor/autoload.php';
AnnotationRegistry::registerLoader(array($loader, 'loadClass'));
use Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver;
AnnotationDriver::registerAnnotationClasses();
return $loader;
The controller and the document/product files were exactly copied from the Symfony site (I only changed the name AcmeStoreBundle to MyTestBundle).
But when I attempt to insert data, I get the following error:
ClassNotFoundException: Attempted to load class "MongoId" from the global namespace in
C:\wamp\www\MongoTest2\vendor\doctrine\mongodb-odm\lib\Doctrine\ODM\MongoDB\Id\AutoGenerator.php line 36.
Did you forget a use statement for this class?
(I cleared the cache and tried again)
Please help me to understand what's going wrong.