1
0
mirror of synced 2024-12-05 03:06:05 +03:00

add debug variable and check for loader

This commit is contained in:
Gusakov Nikita 2013-05-20 17:08:20 +04:00
parent ec57306efe
commit 1f4a65f3e0

View File

@ -1,26 +1,32 @@
<?php
use Doctrine\Common\Cache\ApcCache;
use Doctrine\Common\Cache;
use Doctrine\ORM\EntityManager;
$loader = require __DIR__ . '/../../vendor/autoload.php';
// Set up class loading. You could use different autoloaders, provided by your favorite framework,
// Path to composer autoloader. You can use different provided by your favorite framework,
// if you want to.
$loaderPath = __DIR__ . '/../../vendor/autoload.php';
if(!is_readable($loaderPath)){
throw new LogicException('Run php composer.phar install at first');
}
$loader = require $loaderPath;
// Set up class loading.
$loader->add('Entities', __DIR__);
$loader->add('Proxies', __DIR__);
$debug = true;
$config = new \Doctrine\ORM\Configuration();
// Set up Metadata Drivers
$driverImpl = $config->newDefaultAnnotationDriver(array(__DIR__ . "/Entities"));
$config->setMetadataDriverImpl($driverImpl);
// Set up caches
$cache = new ApcCache;
// Set up caches, depending on $debug variable.
// You can use another variable to define which one of the cache systems you gonna use.
$cache = $debug ? new Cache\ArrayCache : new Cache\ApcCache;
$config->setMetadataCacheImpl($cache);
$config->setQueryCacheImpl($cache);
$config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache);
// Proxy configuration
$config->setProxyDir(__DIR__ . '/Proxies');