0

仮想マシンなしでZendFrameworkボイラープレートを使用しています。

私のApplication.iniは、次のようになります。

;resources.doctrine.orm.entityManagers.default.metadataDrivers.annotationRegistry.annotationFiles[]     = APPLICATION_PATH "/../library/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php"
resources.doctrine.orm.entityManagers.default.metadataDrivers.drivers.0.adapterClass          = "Doctrine\ORM\Mapping\Driver\XmlDriver"
resources.doctrine.orm.entityManagers.default.metadataDrivers.drivers.0.mappingNamespace      = "Square\Entity"
resources.doctrine.orm.entityManagers.default.metadataDrivers.drivers.0.mappingDirs[]         = APPLICATION_PATH "\..\library\Square\Entity"
;resources.doctrine.orm.entityManagers.default.metadataDrivers.drivers.0.annotationReaderClass = "Doctrine\Common\Annotations\AnnotationReader"
;resources.doctrine.orm.entityManagers.default.metadataDrivers.drivers.0.annotationReaderCache = default
;resources.doctrine.orm.entityManagers.default.metadataDrivers.drivers.0.annotationReaderNamespaces.Square = "Square\Entity"

ここからの例のように、CLIでコマンドを実行しました:

http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/tools.html#reverse-engineering

より具体的にはこれ:

$ php doctrine orm:convert-mapping --from-database xml /path/to/mapping-path-converted-to-xml

そして、これにより、次の命名スキーマを使用してxmlファイルが生成されました:{Entity} .dcm.xml

これらのXMLファイルに基づいてエンティティクラスを生成し、次のコマンドを使用してデータベースに保存しようとしました。

    try{
        $this->_em->persist($this->_apikey);
        $this->_em->flush();
    }catch (Exception $e){
        echo "Something went bad --> ".$e;
    }

$this->_apikey = new Square\Entity\Apikeys();コンストラクターメソッドのどこ。

エンティティマネージャは例外をスローします:

exception 'Doctrine\ORM\Mapping\MappingException' with message 'No mapping file found'

Entityクラスがマッピングファイルに対して生成された場合、Doctrineがマッピングファイルを要求するのはなぜですか?

私は何か間違ったことをしていますか?

4

1 に答える 1

0

Doctrine 2.2では、PHPクラスがリバースエンジニアリングされている場合でも、xmlファイルを保持する必要があります。

于 2013-03-20T08:09:51.917 に答える