Use $applicationMode flag in obtaining entity manager example to make sure people understand that different settings for production and development are necessary
This commit is contained in:
parent
d5afa35cb8
commit
974e31a307
@ -84,15 +84,27 @@ with the following minimalist configuration:
|
|||||||
Doctrine\ORM\Configuration;
|
Doctrine\ORM\Configuration;
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
|
if ($applicationMode == "development") {
|
||||||
|
$cache = new \Doctrine\Common\Cache\ArrayCache;
|
||||||
|
} else {
|
||||||
|
$cache = new \Doctrine\Common\Cache\ApcCache;
|
||||||
|
}
|
||||||
|
|
||||||
$config = new Configuration;
|
$config = new Configuration;
|
||||||
$cache = new \Doctrine\Common\Cache\ApcCache;
|
|
||||||
$config->setMetadataCacheImpl($cache);
|
$config->setMetadataCacheImpl($cache);
|
||||||
$driverImpl = $config->newDefaultAnnotationDriver('/path/to/lib/MyProject/Entities');
|
$driverImpl = $config->newDefaultAnnotationDriver('/path/to/lib/MyProject/Entities');
|
||||||
$config->setMetadataDriverImpl($driverImpl);
|
$config->setMetadataDriverImpl($driverImpl);
|
||||||
$config->setQueryCacheImpl($cache);
|
$config->setQueryCacheImpl($cache);
|
||||||
$config->setProxyDir('/path/to/myproject/lib/MyProject/Proxies');
|
$config->setProxyDir('/path/to/myproject/lib/MyProject/Proxies');
|
||||||
$config->setProxyNamespace('MyProject\Proxies');
|
$config->setProxyNamespace('MyProject\Proxies');
|
||||||
|
|
||||||
|
if ($applicationMode == "development") {
|
||||||
|
$config->setAutoGenerateProxyClasses(true);
|
||||||
|
} else {
|
||||||
|
$config->setAutoGenerateProxyClasses(true);
|
||||||
|
}
|
||||||
|
|
||||||
$connectionOptions = array(
|
$connectionOptions = array(
|
||||||
'driver' => 'pdo_sqlite',
|
'driver' => 'pdo_sqlite',
|
||||||
'path' => 'database.sqlite'
|
'path' => 'database.sqlite'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user