forked from doctrine/orm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap.php
41 lines (32 loc) · 1.22 KB
/
bootstrap.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
use Doctrine\Common\Cache;
use Doctrine\ORM\EntityManager;
// 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, 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);
// Proxy configuration
$config->setProxyDir(__DIR__ . '/Proxies');
$config->setProxyNamespace('Proxies');
// Database connection information
$connectionOptions = array(
'driver' => 'pdo_sqlite',
'path' => 'database.sqlite'
);
return EntityManager::create($connectionOptions, $config);