-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli.php
52 lines (41 loc) · 1.07 KB
/
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
42
43
44
45
46
47
48
49
50
51
52
<?php
date_default_timezone_set('UTC');
use Phalcon\DI\FactoryDefault\CLI as CliDI,
Phalcon\CLI\Console as ConsoleApp;
defined('APPLICATION_PATH') || define('APPLICATION_PATH', realpath(dirname(__FILE__)));
$di = new CliDI();
require APPLICATION_PATH . '/config/config.php';
$config = new \Phalcon\Config($settings);
$di->set('config', $config);
$loader = new \Phalcon\Loader();
$loader->registerDirs(
array(
APPLICATION_PATH . '/tasks'
)
);
$loader->register();
$console = new ConsoleApp();
$console->setDI($di);
$arguments = array();
$params = array();
foreach($argv as $k => $arg) {
if($k == 1) {
$arguments['task'] = $arg;
} elseif($k == 2) {
$arguments['action'] = $arg;
} elseif($k >= 3) {
$params[] = $arg;
}
}
if(count($params) > 0) {
$arguments['params'] = $params;
}
define('CURRENT_TASK', (isset($argv[1]) ? $argv[1] : null));
define('CURRENT_ACTION', (isset($argv[2]) ? $argv[2] : null));
try {
$console->handle($arguments);
}
catch (\Phalcon\Exception $e) {
echo $e->getMessage();
exit(255);
}