This repository has been archived by the owner on Jul 17, 2020. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
bootstrap.php
41 lines (33 loc) · 1.45 KB
/
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
31
32
33
34
35
36
37
38
39
40
41
<?php
use Doctrine\DBAL\Driver\PDOSqlite\Driver;
use Doctrine\DBAL\Types\Type;
use Doctrine\ORM\Configuration;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Mapping\Driver\XmlDriver;
use Doctrine\ORM\Proxy\ProxyFactory;
use DoctrineIntegration\Library\AmountType;
use DoctrineIntegration\Library\ISBNType;
use DoctrineIntegration\Library\LibraryIdType;
use Ramsey\Uuid\Doctrine\UuidType;
require_once __DIR__ . '/vendor/autoload.php';
$configuration = new Configuration();
// We use annotations for loading the entities in our system
$configuration->setMetadataDriverImpl(new XmlDriver([__DIR__ . '/mapping']));
// This is needed for Doctrine to generate files required for lazy-loading
$configuration->setProxyDir(__DIR__ . '/data/proxies');
$configuration->setProxyNamespace('DoctrineProxies');
// We are telling Doctrine to always generate files required for lazy-loading. This is a slow operation,
// and shouldn't be done in a production environment.
$configuration->setAutoGenerateProxyClasses(ProxyFactory::AUTOGENERATE_ALWAYS);
Type::addType(UuidType::class, UuidType::class);
Type::addType(AmountType::class, AmountType::class);
Type::addType(ISBNType::class, ISBNType::class);
Type::addType(LibraryIdType::class, LibraryIdType::class);
// Finally creating the EntityManager: our entry point for the ORM
return EntityManager::create(
[
'driverClass' => Driver::class,
'path' => __DIR__ . '/data/test-db.sqlite',
],
$configuration
);