0
votes

I'm using Zend Framework boilerplate without the virtual machine.

My Application.ini, looks like this:

;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"

I have runed the command in CLI as in the example from here :

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

More specifically this one:

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

And this generated my xml files with the following naming schema: {Entity}.dcm.xml

I have generated my Entity classes based on these XML files and then tried saving to the database with:

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

Where $this->_apikey = new Square\Entity\Apikeys(); in the constructor method.

The Entity Manager throws up an exception:

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

Why is Doctrine asking for a mapping file if the Entity class was generated upon them?

Am I doing something wrong?

1
is yr entity named Apikeys.php ? - mpm
@mpm: Yes! My entity is named Apikeys - Gabriel
Is the doctrine command using the same bootstrap process as your application? - Ocramius

1 Answers

0
votes

Doctrine 2.2 requires you keep the xml files even if it has it's PHP class reversed engineered from them.