Domanda

I am trying a different configuration to working with a new Project.

What I want to do is to create a database by writing sql on hand.
After it I want to do a convert-mapping from database to "YML" instead of php annotations. So, to finish it, I want to convert those YML mapping information to Doctrine Entity, inside a ZF2 Module.

I am Using in composer:

"doctrine/doctrine-orm-module" : "0.7.0",
"doctrine/doctrine-module" : "0.7.*",

In global.php configuration

'doctrine' => array(
     'connection' => array(
         // default connection name
         'orm_default' => array(
             'driverClass' => 'Doctrine\DBAL\Driver\PDOMySql\Driver',
             'params' => array(
                 'host'     => 'localhost',
                 'port'     => '3306',
                 'user'     => 'root',
                 'password' => '****',
                 'dbname'   => 'gear',
                 'charset'  => 'utf8'
             ),
         )
     )
 ),

On the Target Module

'doctrine' => array(
    'driver' => array(
        /* This is where you can change the Mapping Driver */
        'orm_default' => array(
            'drivers' => array(
                 'Application\Entity' => 'application_entities_yaml'
             ),
        ),
       'application_entities_yaml' => array(
            'class' => 'Doctrine\ORM\Mapping\Driver\YamlDriver',
            'paths' => array(__DIR__ . '/../src/' .__NAMESPACE__.  '/Yml')
        ),
    ),
),

I am looking to use a custom place to put the YML annotations, on a ZF2 Action I use a exec thats generate this command:

vendor/doctrine/doctrine-module/bin/doctrine-module orm:convert-mapping --namespace="Gear\\Entity\\" --force --from-database yml module/Gear/src/Gear/Yml

Who saves correcty the YML mapping data into the folder module/Gear/src/Gear/Yml It is exactly the path that I put into "application_entities_yaml" in the module config file.

But when i try to finally create the Entitys to get the work done, with this command:

vendor/doctrine/doctrine-module/bin/doctrine-module orm:generate-entities module/Gear/src/

or with

vendor/doctrine/doctrine-module/bin/doctrine-module orm:generate-entities --generate-annotations=1 module/Gear/src/

I got just:

'No Metadata Classes to process.' 

I need to discovery how make Doctrine recognize where i put the metadata classes, to avoid this errors and go on with the project. I'll work with YML entities cuz is the best way to I teach non 'php' programmers write entities by the way. So is important to work with YML.

How to make Doctrine recognize those mapping and convert to entity without problems?

È stato utile?

Soluzione

On the Target Module

Just change the Application\Entity to Module\Entity aka Gear\Entity and it works!

'doctrine' => array(
    'driver' => array(
        /* This is where you can change the Mapping Driver */
        'orm_default' => array(
            'drivers' => array(
                 'Gear\Entity' => 'application_entities_yaml'
             ),
        ),
       'application_entities_yaml' => array(
            'class' => 'Doctrine\ORM\Mapping\Driver\YamlDriver',
            'paths' => array(__DIR__ . '/../src/' .__NAMESPACE__.  '/Yml')
        ),
    ),
),
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top