/**
  * Register a Doctrine Autoloader with the SPL Autoload Stack.
  *
  * On consecutive calls this will do nothing.
  *
  * @return void
  */
 public function registerAutoload()
 {
     if ($this->_registeredAutoloader == false) {
         $config = $this->_options;
         /*if(isset($config['libraryPath'])) {
                         require_once "Zend/Loader/Autoloader/Resource.php";
         
                         $resourceLoader = new Zend_Loader_Autoloader_Resource(array(
                             'basePath'  => $config['libraryPath'],
                             'namespace' => 'Doctrine',
                         ));
                     } else {
                         require_once "Zend/Loader/Autoloader.php";
         
                         $autoloader = Zend_Loader_Autoloader::getInstance();
                         $autoloader->registerNamespace('Doctrine');
                     }*/
         /*if(isset($config['libraryPath'])) {
               require_once $config['libraryPath'].'Doctrine/Common/IsolatedClassLoader.php';
               $classLoader = new \Doctrine\Common\IsolatedClassLoader('Doctrine');
               $classLoader->setBasePath($config['libraryPath']);
               $classLoader->register(); // register on SPL autoload stack
           } else {
               // Assume Doctrine is somewhere in the Include Path
               require_once 'Doctrine/Common/IsolatedClassLoader.php';
               $classLoader = new \Doctrine\Common\IsolatedClassLoader('Doctrine');
               $classLoader->register(); // register on SPL autoload stack
           }*/
         if (isset($config['libraryPath'])) {
             require_once $config['libraryPath'] . 'Doctrine/Common/ClassLoader.php';
             $classLoader = new \Doctrine\Common\ClassLoader('Doctrine');
             $classLoader->setBasePath($config['libraryPath']);
             $classLoader->register();
             // register on SPL autoload stack
         } else {
             // Assume Doctrine is somewhere in the Include Path
             require_once 'Doctrine/Common/ClassLoader.php';
             $classLoader = new \Doctrine\Common\ClassLoader('Doctrine');
             $classLoader->register();
             // register on SPL autoload stack
         }
         $this->_registeredAutoloader = true;
     }
 }
Exemple #2
0
<?php

require '../../lib/Doctrine/Common/ClassLoader.php';
$classLoader = new \Doctrine\Common\ClassLoader();
$classLoader->register();
$classLoader->setBasePath('Doctrine', realpath(__DIR__ . '/../../lib'));
$classLoader->setBasePath('Entities', __DIR__);
$config = new \Doctrine\ORM\Configuration();
$config->setMetadataCacheImpl(new \Doctrine\ORM\Cache\ArrayCache());
$config->setMetadataDriverImpl(new \Doctrine\ORM\Mapping\Driver\YamlDriver(__DIR__ . '/schema'));
$eventManager = new \Doctrine\Common\EventManager();
$connectionOptions = array('driver' => 'pdo_sqlite', 'path' => 'database.sqlite');
$em = \Doctrine\ORM\EntityManager::create($connectionOptions, 'doctrine', $config, $eventManager);