Skip to content

Commit a521a60

Browse files
committed
[Software maintenance - Perfective]
* Change settings to new dependencies. * Configure the doctrine-2 to use utf8 enconding. Add dependencies: * doctrine * firephp * html-compress-twig
1 parent 57e0fcc commit a521a60

File tree

3 files changed

+44
-1
lines changed

3 files changed

+44
-1
lines changed

app/dependencies.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,27 @@
3737
return $logger;
3838
};
3939

40+
// Doctrine
41+
$container['em'] = function ($c) {
42+
$settings = $c->get('settings');
43+
$config = \Doctrine\ORM\Tools\Setup::createAnnotationMetadataConfiguration(
44+
$settings['doctrine']['meta']['entity_path'],
45+
$settings['doctrine']['meta']['auto_generate_proxies'],
46+
$settings['doctrine']['meta']['proxy_dir'],
47+
$settings['doctrine']['meta']['cache'],
48+
false
49+
);
50+
$em = \Doctrine\ORM\EntityManager::create($settings['doctrine']['connection'], $config);
51+
52+
$helpers = new Symfony\Component\Console\Helper\HelperSet(array(
53+
'db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($em->getConnection()),
54+
'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em)
55+
));
56+
57+
return $em;
58+
};
59+
60+
4061
// -----------------------------------------------------------------------------
4162
// Action factories
4263
// -----------------------------------------------------------------------------

app/settings.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,24 @@
2020
'name' => 'app',
2121
'path' => __DIR__ . '/../log/app.log',
2222
],
23+
'doctrine' => [
24+
'meta' => [
25+
'entity_path' => ['app/src/Entities/'],
26+
'auto_generate_proxies' => true,
27+
'proxy_dir' => __DIR__.'/../cache/proxies',
28+
'cache' => null,
29+
],
30+
'connection' => [
31+
'driver' => 'pdo_mysql',
32+
'host' => 'localhost',
33+
'dbname' => 'db-cms',
34+
'user' => 'root',
35+
'password' => 'root',
36+
'charset' => 'utf8',
37+
'driverOptions' => array(
38+
1002 => 'SET NAMES utf8'
39+
)
40+
]
41+
]
2342
],
2443
];

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
"slim/slim": "^3.0",
2121
"slim/twig-view": "^2.0",
2222
"slim/flash": "^0.1.0",
23-
"monolog/monolog": "^1.13"
23+
"monolog/monolog": "^1.13",
24+
"doctrine/orm": "~2.5",
25+
"firephp/firephp-core": "v0.4.0",
26+
"nochso/html-compress-twig": "^2.0"
2427
}
2528
}

0 commit comments

Comments
 (0)