2016-07-29 3 views
1

注釈や名前空間へのパスが間違っているようですが、理由を特定できません。 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'), 
); 
+0

config.ymlで有効にしましたか? – Ziumin

+0

そうだと思います。 'doctrine_mongodb: 接続: デフォルト: サーバー: "MongoDBの://%mongodb_host%:%mongodb_port%" オプション:{} document_managers: デフォルト: auto_mapping:true'を – dMedia

+0

私が尋ね' stof_doctrine_extensions'セクション – Ziumin

答えて

0

検索ソリューション。 autoload.phpにレジストリに注釈ファイルを追加してmanualyする必要があります。documentation 1として

AnnotationRegistry::registerFile(__DIR__ . '/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Mapping/Annotation/Timestampable.php'); 
+0

興味深いのは、上記の変更は、' php bin/console cache:clear'を使ってキャッシュをクリアした後に初めて実行されたときだけです。その後、それは削除することができ、すべて正常に動作します。 – dMedia

+0

また、最初に 'AnnotationRegistry :: registerFile(__DIR__。 '/../ vendor/sensio/framework-extra-bundle/Configuration/Route.php');'を追加する必要があります。それ以外の場合、ルーティングは機能しません。 – dMedia

2

:あなたはapp/config.ymlでアクティブに翻訳可能なものが必要です

stof_doctrine_extensions: 
    mongodb: 
     default: 
      translatable: true 

とも教義に翻訳エンティティマッピングを追加:

doctrine: 
    orm: 
     mappings: 
      gedmo_translatable: 
       type: annotation 
       prefix: Gedmo\Translatable\Document 
       dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Translatable/Document" 
       alias: GedmoTranslatable # (optional) it will default to the name set for the mapping 
       is_bundle: false 
      gedmo_translator: 
       type: annotation 
       prefix: Gedmo\Translator\Document 
       dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Translator/Document" 
       alias: GedmoTranslator # (optional) it will default to the name set for the mapping 
       is_bundle: false 
+0

著者はORMではなくODMを使用します。しかし、オプションは似ているはずです – Ziumin

+0

あなたは正しいです、私はmongoDBを反映するためにconfigに変更しました – NDM

+0

返信いただきありがとうございますが、 'app/config.yml'の変更は必要ありません。これで、autoload.phpの "AnnotationRegistry :: registerFile"がなくても動作します。おそらくそれはいくつかのキャッシュ/ログの問題でした。 – dMedia

関連する問題