Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure Doctrine file mapping driver in ZF2

I have this error:

Fatal error: Uncaught exception 'Doctrine\Common\Persistence\Mapping\MappingException' with message 'File mapping drivers must have a valid directory path, however the given path [path/to/my/entities] seems to be incorrect

and i have this in my module.config.php:

'doctrine' => array(
    'driver' => array(
        // defines an annotation driver with two paths, and names it `my_annotation_driver`
        'my_annotation_driver' => array(
            'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
            'cache' => 'array',
            'paths' => array(
                __DIR__ . '/../src/Realez/Entity',
                'another/path'
            ),
        ),

        // default metadata driver, aggregates all other drivers into a single one.
        // Override `orm_default` only if you know what you're doing
        'orm_default' => array(
            'drivers' => array(
                // register `my_annotation_driver` for any entity under namespace `My\Namespace`
                'Realez/Entity' => 'my_annotation_driver'
            )
        )
    )
)
like image 931
Beltran Moreno Carlos Avatar asked Sep 12 '13 17:09

Beltran Moreno Carlos


1 Answers

I had exactly the same problem. I solved it by creating an empty Entity directory in the location where doctrine expect me to store my entities. All you have to do is create in following location an empty Entity directory: __DIR__ . '/../src/Realez/Entity'.

like image 141
Oskar Avatar answered Sep 23 '22 13:09

Oskar