-
Notifications
You must be signed in to change notification settings - Fork 0
/
new_cli.php
41 lines (34 loc) · 1.01 KB
/
new_cli.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
<?php
use OpsWay\Migration\Processor\ReadWriteProcessor;
use OpsWay\Migration\Reader\ReaderFactory;
use OpsWay\Migration\Writer\WriterFactory;
$config = include 'config.php';
if (defined('CLI_MODE') && CLI_MODE === false) {
die('This can be run only on CLI mode.' . PHP_EOL);
}
echo "Start Time: " . date("d-m-Y H:i:s") . PHP_EOL;
try {
$processor = new ReadWriteProcessor(
ReaderFactory::create($config['reader'], $config['params']),
WriterFactory::create($config['writer'], $config['params']),
function($item, $status, $msg){
static $countItem=0;
static $topString;
$debug = true;
if ((++$countItem % 2) == 0 && $debug) {
$topString .= $countItem." ";
}
if (!$status) {
echo "Warning: " . $msg . print_r($item, true) . PHP_EOL;
}
return $topString;
}
);
//Processing
$processor->processing();
} catch (\Exception $e) {
echo "ERROR: " . $e->getMessage();
} finally {
echo PHP_EOL;
}
"End Time: " . date("d-m-Y H:i:s") . PHP_EOL;