These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | use Doctrine\Common\Cache; |
||
4 | use Doctrine\ORM\EntityManager; |
||
5 | |||
6 | // Path to composer autoloader. You can use different provided by your favorite framework, |
||
7 | // if you want to. |
||
8 | $loaderPath = __DIR__ . '/../../vendor/autoload.php'; |
||
9 | if(!is_readable($loaderPath)){ |
||
10 | throw new LogicException('Run php composer.phar install at first'); |
||
11 | } |
||
12 | $loader = require $loaderPath; |
||
13 | |||
14 | // Set up class loading. |
||
15 | $loader->add('Entities', __DIR__); |
||
16 | $loader->add('Proxies', __DIR__); |
||
17 | |||
18 | $debug = true; |
||
19 | $config = new \Doctrine\ORM\Configuration(); |
||
20 | |||
21 | // Set up Metadata Drivers |
||
22 | $driverImpl = $config->newDefaultAnnotationDriver([__DIR__ . "/Entities"]); |
||
23 | $config->setMetadataDriverImpl($driverImpl); |
||
24 | |||
25 | // Set up caches, depending on $debug variable. |
||
26 | // You can use another variable to define which one of the cache systems you gonna use. |
||
27 | $cache = $debug ? new Cache\ArrayCache : new Cache\ApcCache; |
||
0 ignored issues
–
show
|
|||
28 | $config->setMetadataCacheImpl($cache); |
||
29 | $config->setQueryCacheImpl($cache); |
||
30 | |||
31 | // Proxy configuration |
||
32 | $config->setProxyDir(__DIR__ . '/Proxies'); |
||
33 | $config->setProxyNamespace('Proxies'); |
||
34 | |||
35 | // Database connection information |
||
36 | $connectionOptions = [ |
||
37 | 'driver' => 'pdo_sqlite', |
||
38 | 'path' => 'database.sqlite' |
||
39 | ]; |
||
40 | |||
41 | // Enable second-level cache |
||
42 | $cacheConfig = new \Doctrine\ORM\Cache\CacheConfiguration(); |
||
43 | $cacheDriver = $debug ? new Cache\ArrayCache : new Cache\ApcCache; |
||
0 ignored issues
–
show
The class
Doctrine\Common\Cache\ApcCache has been deprecated with message: since version 1.6, use ApcuCache instead
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.
Loading history...
|
|||
44 | $cacheLogger = new \Doctrine\ORM\Cache\Logging\StatisticsCacheLogger(); |
||
45 | $factory = new \Doctrine\ORM\Cache\DefaultCacheFactory($cacheConfig->getRegionsConfiguration(), $cacheDriver); |
||
46 | |||
47 | if ($debug) { |
||
48 | $cacheConfig->setCacheLogger($cacheLogger); |
||
49 | } |
||
50 | |||
51 | $cacheConfig->setCacheFactory($factory); |
||
52 | $config->setSecondLevelCacheEnabled(true); |
||
53 | $config->setSecondLevelCacheConfiguration($cacheConfig); |
||
54 | |||
55 | return EntityManager::create($connectionOptions, $config); |
||
56 |
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.