-
Notifications
You must be signed in to change notification settings - Fork 13
/
console
executable file
·63 lines (52 loc) · 2.04 KB
/
console
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env php
<?php
use App\Services\Settings;
use DI\ContainerBuilder;
use Doctrine\Migrations\Configuration\EntityManager\ExistingEntityManager;
use Doctrine\Migrations\Configuration\Migration\ConfigurationArray;
use Doctrine\Migrations\Tools\Console\Command;
use Doctrine\Migrations\DependencyFactory;
use Doctrine\ORM\EntityManager;
use Symfony\Component\Console\Application;
// Set the absolute path to the root directory.
$rootPath = realpath(__DIR__);
// Include the composer autoloader.
include_once ($rootPath . '/vendor/autoload.php');
// At this point the container has not been built. We need to load the settings manually.
$settings = Settings::load();
// DI Builder
$containerBuilder = new ContainerBuilder();
if (!$settings->get('debug')) {
// Compile and cache container.
$containerBuilder->enableCompilation($settings->get('cache_dir') . '/container');
}
// Set up dependencies
$containerBuilder->addDefinitions($rootPath . '/config/dependencies.php');
// Build PHP-DI Container instance
$container = $containerBuilder->build();
// Doctrine migration
$dependencyFactory = DependencyFactory::fromEntityManager(
new ConfigurationArray($container->get(Settings::class)->get('doctrine.migrations')),
new ExistingEntityManager($container->get(EntityManager::class))
);
// Build the app
$cli = new Application();
$cli->add($container->get(\App\Console\CacheClearConsoleCommand::class));
$cli->addCommands([
new Command\DumpSchemaCommand($dependencyFactory),
new Command\ExecuteCommand($dependencyFactory),
new Command\GenerateCommand($dependencyFactory),
new Command\LatestCommand($dependencyFactory),
new Command\ListCommand($dependencyFactory),
new Command\MigrateCommand($dependencyFactory),
new Command\RollupCommand($dependencyFactory),
new Command\StatusCommand($dependencyFactory),
new Command\SyncMetadataCommand($dependencyFactory),
new Command\VersionCommand($dependencyFactory),
]);
try {
exit($cli->run());
} catch (Throwable $exception) {
echo $exception->getMessage();
exit(1);
}