将Doctrine 2 ORM实体存储在不同的位置

Disclaimer: I'm new to Doctrine

I'm currently building a project that requires extreme modularity and flexibility, and have 2 questions related to it. My project considers the following an "ideal" simplified structure:

PackageA
    PackageA.php
    PackageA.orm.yml
PackageB
    PackageB.php
    PackageB.orm.yml
PackageC
    PackageC.php
    PackageC.orm.yml

Because these packages are added or removed fairly frequently, my goal is for each package to define its own mapping for persistence (as shown above). However, the examples of doctrine configuration I've seen, place all the mapping files (xml or yml) into a single directory, in that case my structure would be:

PackageA
    PackageA.php
PackageB
    PackageB.php
PackageC
    PackageC.php
Config
    PackageA.orm.yml
    PackageB.orm.yml
    PackageC.orm.yml

Question 1: Is it possible to keep each mapping configuration file in a different location (like first example), and if so, how do you instantiate an EntityManager with that kind of configuration (I've read the Docs for Setup and can't seem to find this capability).

Question 2: I've seen how to create Schemas using the command line tool, but ideally I would like to each package to create its own schema, so if PackageD is installed onto a system and its schema doesn't exist yet, it is able to create it on the fly. Is that possible with Doctrine?

Note: I've seen some ability for creating schemas on demand with SchemaTool, but it seems limited to create all the schemas, is that true?

Answering my own question for those who need this:

Splitting up the location of all the Maps and Entities is most easily accomplished using the SimplifiedYamlDriver. Here's a quick example:

<?php

// Generate an array of your structure
$maps = array(
 'PackageA/Entities' => 'Your\PackageA\Entities',
 'PackageB/Entities' => 'Your\PackageB\Entities'
);

$config = new Doctrine\ORM\Configuration;
$driver = new Doctrine\ORM\Mapping\Driver\SimplifiedYamlDriver($maps);

$config->setMetadataDriverImpl($driver);

// ... finish configuration
// ... create connection params $conn

$em = new Doctrine\ORM\EntityManager($conn, $config);

The above code (plus pseudo code) creates a new entity manager with access to Entities in more modular structure. Remember that in your Entity.orm.yml mapping files you should use the fully qualified namespace of the actual Entities.

More details here: Yaml Mapping

Q1:It maybe possible but you have to write in core codes of doctrine(not preferrable) Q2: Yes that is the beauty of using orm. You have to run command line script for this like doctrine tools reference.