-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli-config.php
31 lines (24 loc) · 952 Bytes
/
cli-config.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
<?php
declare(strict_types = 1);
require 'vendor/autoload.php';
use Doctrine\Migrations\Configuration\Migration\PhpFile;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Tools\Setup;
use Doctrine\Migrations\Configuration\EntityManager\ExistingEntityManager;
use Doctrine\Migrations\DependencyFactory;
use Dotenv\Dotenv;
$dotenv = Dotenv::createImmutable(__DIR__);
$dotenv->load();
$config = new PhpFile('migrations.php'); // Or use one of the Doctrine\Migrations\Configuration\Configuration\* loaders
$params = [
'host' => $_ENV['DB_HOST'],
'user' => $_ENV['DB_USER'],
'password' => $_ENV['DB_PASS'],
'dbname' => $_ENV['DB_DATABASE'],
'driver' => $_ENV['DB_DRIVER'] ?? 'pdo_mysql',
];
$entityManager = EntityManager::create(
$params,
Setup::createAttributeMetadataConfiguration([__DIR__ . '/app/Entity'])
);
return DependencyFactory::fromEntityManager($config, new ExistingEntityManager($entityManager));