I must integrate Doctrine 2 ORM into WordPress to be used within the plug ins I am developing. There's presently a wordpress plugin that provides Doctrine 1.2.3 ORM support in WordPress, although not v2.

The greatest problem I am getting is the fact that I do not know how Doctrine 2 ORM interacts with my code particularly, what their configuration code generates for me and where I ought to move from here:

// 3.1.1
require dirname( __FILE__ ) . '/lib/Doctrine/ORM/Tools/Setup.php';
$lib = dirname( __FILE__ ) . '/lib';
Doctrine\ORM\Tools\Setup::registerAutoloadDirectory($lib);

// 3.1.2
use Doctrine\ORM\EntityManager,
    Doctrine\ORM\Configuration;

if($applicationMode == "development") {
    $cache = new \Doctrine\Common\Cache\ArrayCache;
} else {
    $cache = new \Doctrine\Common\Cache\ApcCache;
}

$config = new Configuration;
$config->setMetadataCacheImpl($cache);
$driverImpl = $config->newDefaultAnnotationDriver('/path/to/lib/MyProject/Entities');
$config->setMetadataDriverImpl($driverImpl);
$config->setQueryCacheImpl($cache);
$config->setProxyDir('/path/to/myproject/lib/MyProject/Proxies');
$config->setProxyNamespace('MyProject\Proxies');

if ($applicationMode == "development") {
    $config->setAutoGenerateProxyClasses(true);
} else {
    $config->setAutoGenerateProxyClasses(false);
}

$connectionOptions = array(
    'driver' => 'pdo_sqlite',
    'path' => 'database.sqlite'
);

$em = EntityManager::create($connectionOptions, $config);

I'd ongoing reading through through parts of the documentation as much as section 8 and also have some understanding. My questions are:

  1. Is configuration enough to let me use Doctrine 2 ORM during my plug ins?

  2. Are there more key steps I am missing before dealing with Doctrine 2 ORM? The WordPress wordpress plugin appears to instantly generate all the appropriate classes in the database. I just read the documentation a couple of occasions, however i seem like I am missing some large step... or possibly Doctrine 2 ORM is simply much different?

  3. May be the EntityManager some global variable will be able to use throughout my organizations?

  4. I suppose I must link everything together, @Entity inside a file isn't enough for Doctrine to understand in which the entity is. Can there be somewhere within the documentation that defines this?

If anybody can offer a fast rundown of methods everything in concert with: configuration, organizations, etc. Or provide any obvious cut lessons that could be available, I'd really be thankful.