-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap.php
30 lines (24 loc) · 920 Bytes
/
bootstrap.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
<?php
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\ORMException;
use Doctrine\ORM\Tools\Setup;
require_once "vendor/autoload.php";
//-------------------------------- DATABASE --------------------------------
// Create a simple "default" Doctrine ORM configuration for Annotations
$isDevMode = true;
$config = Setup::createAnnotationMetadataConfiguration(array(__DIR__ . "/src/Entity"), $isDevMode);
// Setting up Database configuration parameters
if (!getenv('DATABASE_URL')){ // Check if env is defined
die("No DATABASE_URL variable set in the environment");
}
$connectionParams = array(
'url' => getenv('DATABASE_URL'),
'driver' => 'pdo_mysql'
);
// Obtaining the entity manager
/** @var \Doctrine\ORM\EntityManagerInterface $entityManager */
try {
$entityManager = EntityManager::create($connectionParams, $config);
} catch (ORMException $e) {
die("Can't create Database connection");
}