Closed titomiguelcosta closed 11 years ago
I don't use annotation, @mavimo may know more about this than me, any idea ?
But, after reading doctrine code, it seems ok for me.
Maybe we could registerAnnotationClasses()
in case user wants to use annotation driver
In accord to documentation you need to register your documents autoloading, eg:
// Configure MongoDB service provider
$app->register(new MongoDBODMServiceProvider(), array(
'doctrine.odm.mongodb.connection_options' => array(
'database' => $_SERVER['MONGODB_DB'],
'host' => $_SERVER['MONGODB_SERVER'],
'port' => $_SERVER['MONGODB_PORT'],
),
'doctrine.odm.mongodb.documents' => array(
0 => array(
'type' => 'annotation',
'path' => array(
__DIR__ . '/Mavimo',
),
'namespace' => 'Mavimo'
),
),
// 'doctrine.odm.mongodb.documents' => array(),
'doctrine.odm.mongodb.proxies_dir' => DIR_CACHE . '/doctrine/odm/mongodb/Proxy',
'doctrine.odm.mongodb.proxies_namespace' => 'DoctrineMongoDBProxy',
'doctrine.odm.mongodb.auto_generate_proxies' => true,
'doctrine.odm.mongodb.hydrators_dir' => DIR_CACHE . '/doctrine/odm/mongodb/Hydrator',
'doctrine.odm.mongodb.hydrators_namespace' => 'DoctrineMongoDBHydrator',
'doctrine.odm.mongodb.metadata_cache' => new Doctrine\Common\Cache\ApcCache(),
));
In document class:
namespace Mavimo\Entity;
use Mavimo\Entity\Base;
use Doctrine\ODM\MongoDB\Mapping\Annotations as ORM;
/**
* @ORM\Document(collection="events")
*/
class Event extends Base
{
/**
* @ORM\Id
*/
private $id;
/**
* @ORM\String
*/
private $title;
// Add more...
}
in your code you use @Doctrine
are you sure you need to have @
in your code?
While trying to run the odm:generate:documents command I encountered the same error as @titomiguelcosta. After adding the
AnnotationDriver::registerAnnotationClasses();
the command run successfully. I'll send a pull request with the fix I used.
Yes, a PR is wecome ! thanks !
Fixed in #6 , available in tag 0.1.1
I only managed to get this service to work in my Silex project when I added the annotation autoloader:
Before, I was getting the following error:
Not sure if I'm doing something wrong or this the autoloading for annotation is missing.
Although we have the official documentation, It would be nice to have an example of a Document.