forked from Coderockr/orcamentos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli-config.php
40 lines (28 loc) · 1.26 KB
/
cli-config.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
<?php
$loader = require __DIR__.'/vendor/autoload.php';
$loader->add('Orcamentos', __DIR__.'/src');
$configValues = require __DIR__ . '/config/config.php';
use Doctrine\ORM\Tools\Setup;
use Doctrine\ORM\EntityManager;
use Doctrine\Common\Annotations\AnnotationRegistry;
AnnotationRegistry::registerFile(__DIR__.'/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php');
// configuration (2)
$config = new \Doctrine\ORM\Configuration();
// Proxies (3)
$config->setProxyDir(__DIR__ . '/tmp');
$config->setProxyNamespace('Proxies');
$config->setAutoGenerateProxyClasses(true);
// Driver (4)
$driverImpl = new Doctrine\ORM\Mapping\Driver\AnnotationDriver(
new Doctrine\Common\Annotations\AnnotationReader(),
array(__DIR__.'/src/Orcamentos/Model')
);
$config->setMetadataDriverImpl($driverImpl);
$cache = new \Doctrine\Common\Cache\ApcCache();
$config->setMetadataCacheImpl($cache);
$connectionOptions = $configValues['db.options'];
$em = \Doctrine\ORM\EntityManager::create($connectionOptions, $config);
return $helperSet = new \Symfony\Component\Console\Helper\HelperSet(array(
'db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($em->getConnection()),
'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em)
));