I'm trying to use the DoctrineMongoDBBundle, however, i'm running into an issue.
In my config.yml, I have:
doctrine_mongodb:
connections:
default:
server: mongodb://localhost:27017
options:
connect: true
default_database: symfony2
document_managers:
default:
auto_mapping: true
My User.php class:
<?php
namespace HALL\HelloWorldBundle\Document;
use FOS\UserBundle\Document\User as BaseUser;
use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;
/**
* @MongoDB\Document
*/
class User extends BaseUser
{
/** @MongoDB\Id(strategy="auto") */
protected $id;
public function __construct()
{
parent::__construct();
// your own logic
}
}
When I run the command:
php app/console doctrine:mongodb:generate:documents HALLHelloWorldBundle
I get the following error:
[Doctrine\Common\Annotations\AnnotationException]
[Semantical Error] The annotation "@Doctrine\ODM\MongoDB\Mapping\Annotations\Document" in class HALL\HelloWorldBundle\Document\User does not exist, or could not be auto-loaded.
Any ideas why? The annotation is clearly referenced.
Registering the annotations as in Jamie's solution did not work for me. It solved this problem but meant that the annotations object could not be unserialized from the cache . Registering the annotations like this:
AnnotationRegistry::registerFile(__DIR__.'/../vendor/doctrine-mongodb-odm/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/DoctrineAnnotations.php');
Meant that the original issue was resolved without introducing the issue relating to the cache.