aboutsummaryrefslogtreecommitdiff
path: root/src/Model/doctrine-bootstrap.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Model/doctrine-bootstrap.php')
-rw-r--r--src/Model/doctrine-bootstrap.php34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/Model/doctrine-bootstrap.php b/src/Model/doctrine-bootstrap.php
new file mode 100644
index 0000000..13db87f
--- /dev/null
+++ b/src/Model/doctrine-bootstrap.php
@@ -0,0 +1,34 @@
1<?php
2// src/Model/doctrine-bootstrap.php
3
4declare(strict_types=1);
5
6use Doctrine\ORM\ORMSetup;
7use Doctrine\DBAL\DriverManager;
8use Doctrine\ORM\EntityManager;
9use App\Service\Config;
10
11//require_once "../vendor/autoload.php";
12
13// Create a simple "default" Doctrine ORM configuration for Attributes
14$config = ORMSetup::createAttributeMetadataConfiguration(
15 //paths: array(__DIR__.'/entities'),
16 paths: array('../src/Model/Entity'),
17 isDevMode: true,
18 // true: cache en mémoire vive
19 // false: utilisation de APCu ou redis ou memcache
20);
21
22// configuring the database connection
23$connection = DriverManager::getConnection([
24 'driver' => Config::$db_driver,
25 'user' => Config::$user,
26 'password' => Config::$password,
27 'host' => Config::$db_host,
28 'dbname' => Config::$database,
29], $config);
30
31// obtaining the entity manager
32$entityManager = new EntityManager($connection, $config);
33
34foreach($entityManager->getMetadataFactory()->getAllMetadata() as $class){} \ No newline at end of file