generated from AntoninoM90/slim4-doctrine2-skeleton
-
Notifications
You must be signed in to change notification settings - Fork 2
/
cli-config.php
39 lines (28 loc) · 1.03 KB
/
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
32
33
34
35
36
37
38
39
<?php
declare(strict_types=1);
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Tools\Console\ConsoleRunner;
use DI\ContainerBuilder;
use Slim\Factory\ServerRequestCreatorFactory;
require __DIR__ . '/vendor/autoload.php';
$containerBuilder = new ContainerBuilder();
if (false) {
// Should be set to true in production
$containerBuilder->enableCompilation(__DIR__ . '/../var/cache');
}
// Create Request object from globals
$serverRequestCreator = ServerRequestCreatorFactory::create();
$request = $serverRequestCreator->createServerRequestFromGlobals();
// Set up settings
$settings = require __DIR__ . '/app/settings.php';
$settings($containerBuilder);
// Set up dependencies
$dependencies = require __DIR__ . '/app/dependencies.php';
$dependencies($containerBuilder, $request);
// Build PHP-DI Container instance
$container = $containerBuilder->build();
// Get the Entity Manager from the container
$entityManager = $container->get(EntityManager::class);
ConsoleRunner::run(
ConsoleRunner::createHelperSet($entityManager)
);