Hi, everyone!
I'm building a PHP site and I decided to go with Doctrine as DBAL and ORM. I'm a bit rusty on my PHP skills, so please help me understand one thing.
The way to configure Doctrine, as specified in their docs is to execute code like this:
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'
);
What I'm puzzled about is how should you execute this code. Is it something you put in a config.php file and include in each of your pages, basically executing this each time a page is processed? Or am I supposed to do this configuration once?
On a related note - please help me understand how setting cache to ArrayCache instead of APC cache helps me during development?
Thanks!