-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconsole.php
More file actions
34 lines (30 loc) · 1.44 KB
/
console.php
File metadata and controls
34 lines (30 loc) · 1.44 KB
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
#!!/usr/bin/env php
<?php
define('ROOT_DIR', realpath(__DIR__));
$loader = require_once ROOT_DIR . '/vendor/autoload.php';
// Configuration
$configuration = [];
if (file_exists(ROOT_DIR . '/config/parameters.php')) {
$configuration = require_once ROOT_DIR . '/config/parameters.php';
} else {
die('Please, create copy "parameters.php.dist" to "parameters.php" in config folder!');
}
$connection = \Doctrine\DBAL\DriverManager::getConnection($configuration['database'], new \Doctrine\DBAL\Configuration());
$platform = $connection->getDatabasePlatform();
$platform->registerDoctrineTypeMapping('enum', 'string');
$configuration = new \Doctrine\DBAL\Migrations\Configuration\Configuration($connection);
$configuration->setMigrationsNamespace('Dime\Api\Migrations');
$configuration->setMigrationsDirectory(ROOT_DIR . '/src/Dime/Api/Migrations');
$configuration->setMigrationsTableName('migration_versions');
$helpers = new Symfony\Component\Console\Helper\HelperSet([
'db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($connection),
'dialog' => new Symfony\Component\Console\Helper\QuestionHelper(),
'configuration' => new \Doctrine\DBAL\Migrations\Tools\Console\Helper\ConfigurationHelper($connection, $configuration)
]);
$cli = new \Symfony\Component\Console\Application('Dime Timetracker');
$cli->setCatchExceptions(true);
$cli->setHelperSet($helpers);
$cli->addCommands([
new Dime\Api\Command\InstallCommand()
]);
$cli->run();