Single XML configuration for Doctrine

319 views Asked by At

According to the docs:

You can add a global file and add multiple entities in this file.

What I tried is:

$driver = new \Doctrine\ORM\Mapping\Driver\SimplifiedXmlDriver(array("orm-xml"));
$driver->setGlobalBasename('global');

// ...

$em->getClassMetadata('something_Application');

I have a directory named orm-xml and it contains a file global.orm.xml as the documentation suggests. When I try to run my script I get:

uncaught exception: No mapping file found named 'omething_Application.orm.xml' for class 'something_Application'.

The first thing I noticed that the error message eats the first caharacter of the classname. And there is the main problem: it is trying to read config on a one-xml-per-class basis, why doesn't it use the global file I specified?

1

There are 1 answers

0
vbence On BEST ANSWER

The answer was something that examples did not show: the addPaths method:

$driver = new \Doctrine\ORM\Mapping\Driver\SimplifiedXmlDriver(array("orm-xml"));
$driver->setGlobalBasename('global');
$driver->addPaths(array("orm-xml"));

Note that I was thinking that the constructor's parameter is for this. I still don't know what it is really for.