我想在Laravel4.2中使用couchdb,但是我不断地出错。最后一个问题是:
语义错误:类IO\Documents\ "@Doctrine\ODM\CouchDB\Mapping\Annotations\Document“中的注释不存在,或者无法自动加载。
我主要复制了sandbox/bootstrap.php,并尝试了从以前的回答中得到的几条建议。以下是我目前所拥有的:
我的composer.json有:
"require": {
"laravel/framework": "4.2.*",
"symfony/console": ">=2.0",
"doctrine/dbal": "2.5.*@dev",
"doctrine/migrations": "1.0.*@dev",
"doctrine/common": "2.4.*",
"doctrine/couchdb": "@dev",
"doctrine/couchdb-odm": "dev-master"
},我也试图把这一学说/共同的观点写在“自传”一节中,但这并没有真正起到任何作用。
文章类:
namespace IO\Documents;
use Doctrine\ODM\CouchDB\Mapping\Annotations\Document;
use Doctrine\Common\Collections\ArrayCollection;
/**
* @Document(indexed=true)
*/
class Article {}我的财务主任:
$database = "test";
$httpClient = new \Doctrine\CouchDB\HTTP\SocketClient();
$resp = $httpClient->request('PUT', '/' . $database);
$reader = new \Doctrine\Common\Annotations\AnnotationReader();
// doesn't exist so I comment out
// $reader->registerAnnotationClasses('Doctrine\ODM\CouchDB\Mapping\\');
$paths = __DIR__ . "/Documents";
$metaDriver = new \Doctrine\ODM\CouchDB\Mapping\Driver\AnnotationDriver($reader, $paths);
$config = new \Doctrine\ODM\CouchDB\Configuration();
$config->setProxyDir(\sys_get_temp_dir());
$config->setMetadataDriverImpl($metaDriver);
$config->setLuceneHandlerName('_fti');
$couchClient = new \Doctrine\CouchDB\CouchDBClient($httpClient, $database);
$dm = \Doctrine\ODM\CouchDB\DocumentManager::create($couchClient, $config);
$article1 = new Article();
$article1->setTitle("Who is John Galt?");
$article1->setBody("Find out!");
$dm->persist($article1);
$dm->flush();
$dm->clear();我仍然是couchdb的初学者,所以在混乱中累积起来。
发布于 2014-08-23 14:47:57
composer dump-autoload成功了。
另外,下面是对我的控制器的更新:
$annotationNs = 'Doctrine\\ODM\\CouchDB\\Mapping\\Annotations';
$couchPath = '/path/to/vendor/doctrine/couchdb-odm/lib';
\Doctrine\Common\Annotations\AnnotationRegistry::registerAutoloadNamespace($annotationNs, $couchPath);
$databaseName = "test";
$documentPaths = array("IO\Documents");
$httpClient = new \Doctrine\CouchDB\HTTP\SocketClient();
$dbClient = new \Doctrine\CouchDB\CouchDBClient($httpClient, $databaseName);
$config = new \Doctrine\ODM\CouchDB\Configuration();
$metadataDriver = $config->newDefaultAnnotationDriver($documentPaths);
$config->setProxyDir(__DIR__ . "/proxies");
$config->setMetadataDriverImpl($metadataDriver);
$dm = new \Doctrine\ODM\CouchDB\DocumentManager($dbClient, $config);
$article1 = new Article();
$article1->setTitle("Who is John Galt?");
$article1->setBody("Find out!");
$dm->persist($article1);
$dm->flush($article1);我的文章课:
<?php
namespace IO\Documents;
use Doctrine\ODM\CouchDB\Mapping\Annotations as CouchDB;
/**
* @Document
*/
class Article ()https://stackoverflow.com/questions/25444853
复制相似问题