-
Notifications
You must be signed in to change notification settings - Fork 0
/
laminator-db.php
56 lines (42 loc) · 1.46 KB
/
laminator-db.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env php
<?php
namespace DbTableInstigator;
use Laminas\ConfigAggregator\{
ConfigAggregator,
PhpFileProvider,
LaminasConfigProvider
};
use Laminas\Db\Adapter\Adapter as DbAdapter;
use Laminas\Db\Metadata;
use Symfony\Component\Console\Application;
require __DIR__ . '/vendor/autoload.php';
$wDir = getcwd();
// Config
$mvcConfigPattern = $wDir . '/config/autoload/*{global,local,.global,.local}.{php}';
$customConfigFile = __DIR__ . '/app.ini';
$configAggregator = new ConfigAggregator([
new PhpFileProvider($mvcConfigPattern),
new LaminasConfigProvider($customConfigFile),
]);
$config = $configAggregator->getMergedConfig();
// Db Adapter
if (!isset($config['db'])) {
die("\e[1;37;41mCannot instantiate DbAdapter: Missing db-config\e[0m\n");
}
$dbAdapter = new DbAdapter($config['db']);
$dbMetadata = Metadata\Source\Factory::createSourceFromAdapter($dbAdapter);
// Symfony console application
$application = new Application(App::APP_NAME, App::APP_VERSION);
$formCommand = new Command\FormCommand();
$formCommand
->setAppDir($wDir)
->setDbMetadata($dbMetadata);
$application->add($formCommand);
$entityCommand = new Command\EntityCommand();
$entityCommand
->setAppDir($wDir)
->setDbMetadata($dbMetadata);
$application->add($entityCommand);
#$application->add(new Command\TableToFormCommand($dbAdapter, $wdir, $config));
#$application->add(new Command\TableToTableClassCommand($dbAdapter, $wdir, $config));
$application->run();