注釈や名前空間へのパスが間違っているようですが、理由を特定できません。 php bin/console doctrine:mongodb:mapping:info
出力Symfony2注釈「@Gedmo Mapping Annotation Timestampable」が存在しないか、自動ロードできない
[FAIL] AppBundle\Document\Test\Test
[Semantical Error] The annotation "@Gedmo\Mapping\Annotation\Timestampable" in property AppBundle\Document\Test\Test::$createdAt does not exist, or could not be auto-loaded.
エンティティファイル:
<?php
namespace AppBundle\Document\Test;
use AppBundle\Document\Question\Question;
use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;
use Gedmo\Mapping\Annotation as Gedmo;
/**
* @MongoDB\Document(repositoryClass="AppBundle\Document\Test\TestRepository")
* @MongoDB\HasLifecycleCallbacks()
*/
class Test
{
/**
* @MongoDB\Id(strategy="auto")
*/
protected $id;
/**
* @MongoDB\Field(type="string")
*/
protected $lastName;
/**
* @Gedmo\Timestampable(on="create")
* @MongoDB\Timestamp()
*/
protected $createdAt;
stackoverflowのは、すでにほとんどのコードは私のポストであることを私に警告するが、私は、私はcomposer.jsonセクションを示さなければならないと思う:
"require": {
"alcaeus/mongo-php-adapter": "^1.0",
"symfony/symfony": "3.*",
"doctrine/orm": "^2.5",
"doctrine/doctrine-bundle": "^1.6",
"doctrine/common": "~2.4",
"doctrine/doctrine-cache-bundle": "^1.2",
"doctrine/mongodb-odm": "^1.0",
"doctrine/mongodb-odm-bundle": "3.*",
"gedmo/doctrine-extensions": "^2.4",
"symfony/monolog-bundle": "^2.8",
"sensio/distribution-bundle": "^5.0",
"sensio/framework-extra-bundle": "^3.0.2",
"incenteev/composer-parameter-handler": "^2.0",
"friendsofsymfony/user-bundle": "dev-master",
"stof/doctrine-extensions-bundle": "^1.2",
},
はい、私はAnnotationDriver::registerAnnotationClasses();
をautoload.phpに持っています。私は物事がvendor/composer/autoload_namespaces.php
を見てきた、あまりにもOKらしい:働い
<?php
// autoload_namespaces.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
[...]
'Gedmo\\' => array($vendorDir . '/gedmo/doctrine-extensions/lib'),
'Doctrine\\ORM\\' => array($vendorDir . '/doctrine/orm/lib'),
'Doctrine\\ODM\\MongoDB' => array($vendorDir . '/doctrine/mongodb-odm/lib'),
'Doctrine\\MongoDB' => array($vendorDir . '/doctrine/mongodb/lib'),
'Doctrine\\DBAL\\' => array($vendorDir . '/doctrine/dbal/lib'),
'Doctrine\\Common\\Lexer\\' => array($vendorDir . '/doctrine/lexer/lib'),
'Doctrine\\Common\\Inflector\\' => array($vendorDir . '/doctrine/inflector/lib'),
'Doctrine\\Common\\Collections\\' => array($vendorDir . '/doctrine/collections/lib'),
'Doctrine\\Common\\Annotations\\' => array($vendorDir . '/doctrine/annotations/lib'),
'Behat\\Transliterator' => array($vendorDir . '/behat/transliterator/src'),
);
config.ymlで有効にしましたか? – Ziumin
そうだと思います。 'doctrine_mongodb: 接続: デフォルト: サーバー: "MongoDBの://%mongodb_host%:%mongodb_port%" オプション:{} document_managers: デフォルト: auto_mapping:true'を – dMedia
私が尋ね' stof_doctrine_extensions'セクション – Ziumin