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.
require_once __DIR__.'/../vendor/doctrine-mongodb-odm/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/DoctrineAnnotations.php'; Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver::registerAnnotationClasses();
However, yours seems like a better solution! Accepted yours at the answer. – Marquardt