私はzf2用Doctrine MongoODM Moduleをロードしました。私はコントローラの中にドキュメントマネージャーを持っていて、ドキュメントを残そうとするまでうまくいっていました。このエラーで失敗します。Annotations名前空間がロードされていませんDoctrineMongoODMModule for Zend Framework 2
"[意味的なエラー] SdsCore \ Document \ Userクラスの注釈" @Document "はインポートされませんでした。
私のドキュメントクラスで$name = 'Document'
、輸入された注釈クラスがここ'Doctrine\ODM\MongoDB\Mapping\Annotations\Doctrine'
あるので、それが失敗したDocParser.php if ('\\' !== $name[0] && !$this->classExists($name)) {
のこの行に失敗するようだ:
namespace SdsCore\Document;
/** @Document */
class User
{
/**
* @Id(strategy="UUID")
*/
private $id;
/**
* @Field(type="string")
*/
private $name;
/**
* @Field(type="string")
*/
private $firstname;
public function get($property)
{
$method = 'get'.ucfirst($property);
if (method_exists($this, $method))
{
return $this->$method();
} else {
$propertyName = $property;
return $this->$propertyName;
}
}
public function set($property, $value)
{
$method = 'set'.ucfirst($property);
if (method_exists($this, $method))
{
$this->$method($value);
} else {
$propertyName = $property;
$this->$propertyName = $value;
}
}
}
私のアクションコントローラは次のとおりです。
public function indexAction()
{
$dm = $this->documentManager;
$user = new User();
$user->set('name', 'testname');
$user->set('firstname', 'testfirstname');
$dm->persist($user);
$dm->flush;
return new ViewModel();
}
ありがとう:あなたは、だからここにあなたの文書を修正する方法を示しますDoctrine\Common documentation
でそれについての詳細を読むことができます。 mongoコンポネントの教義サイト上のドキュメントには、アノテーションに追加されたODM \名前空間は表示されません。私はまだあなたのソリューションを使用していない、私は再びコードにアクセスできるように数日待つ必要があります。私は結果を投稿します。 – superdweebie
あなたは依然としてドキュメント内のソリューションを使用することができますが、それはもう示唆された方法ではなく、ODMでORMを使用するケース(たとえば@Idを取る...)と競合するので問題があります。 – Ocramius
溶液がテストされました。起動して実行しています。ありがとう。 – superdweebie