-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli-config.php
More file actions
57 lines (47 loc) · 1.59 KB
/
cli-config.php
File metadata and controls
57 lines (47 loc) · 1.59 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
require_once __DIR__.'/vendor/autoload.php';
use Doctrine\ORM\Tools\Setup;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\ORMException;
use Doctrine\ORM\Tools\Console\ConsoleRunner;
use Doctrine\ORM\Mapping\Driver\AnnotationDriver;
use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Common\Annotations\AnnotationRegistry;
use Doctrine\Common\Annotations\AnnotationException;
use Symfony\Component\Yaml\Yaml;
$config = Yaml::parse(file_get_contents(__DIR__.'/config.yml'));
$paths = array();
foreach ($config['modules'] as $module) {
$paths[] = $module['path'] . "/src";
}
$isDevMode = $config['general']['dev_mode'];
// the connection configuration
$dbParams = array(
'driver' => $config['db']['driver'],
'user' => $config['db']['user'],
'password' => $config['db']['password'],
'host' => $config['db']['host'],
'dbname' => $config['db']['dbname']
);
$config = Setup::createConfiguration($isDevMode);
try{
$driver = new AnnotationDriver(new AnnotationReader(), $paths);
}catch (AnnotationException $ae)
{
echo $ae->getMessage();
}
// registering noop annotation autoloader - allow all annotations by default
AnnotationRegistry::registerLoader('class_exists');
$config->setMetadataDriverImpl($driver);
$config->setProxyDir('proxy');
try{
$entityManager = EntityManager::create($dbParams, $config);
}catch (ORMException $oe)
{
echo $oe->getMessage();
}
$helperSet = ConsoleRunner::createHelperSet($entityManager);
// Retrieve default console application
$cli = ConsoleRunner::createApplication($helperSet);
// Runs console application
$cli->run();