forked from phanbook/phanbook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli
78 lines (65 loc) · 2.02 KB
/
cli
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
/**
* a cli launcher and a cli script that launches phalcon tasks
*
* @example php cli.php [task] [action] [param1 [param2 ...]]
* @example php cli.php Example index
* @example php cli.php Example index --debug --single --no-record
*/
define('ROOT_DIR', __DIR__ . '/');
define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'local'));
date_default_timezone_set('UTC');
// Necessary requires to get things going
require ROOT_DIR . '/vendor/autoload.php';
require ROOT_DIR . '/core/common/tools/cli/PhpError.php';
require ROOT_DIR . '/core/common/tools/cli/IRun.php';
require ROOT_DIR . '/core/common/tools/cli/Output.php';
require ROOT_DIR . '/core/common/Console.php';
use Phalcon\DI\FactoryDefault\CLI;
use Phanbook\Console as ConsoleApp;
// Capture runtime errors
register_shutdown_function(['Phanbook\Tools\Cli\PhpError', 'runtimeShutdown']);
try {
$app = new ConsoleApp( new CLI());
// Record any php warnings/errors
set_error_handler(['Phanbook\Tools\Cli\PhpError', 'errorHandler']);
// Check if only run single instance
if ($key = array_search('--single', $argv)) {
$app->setSingleInstance(true);
// Ensure pid removes even on fatal error
register_shutdown_function([$app, 'removeProcessInstance']);
}
// Check if logging to database
if ($key = array_search('--record', $argv)) {
$app->setRecording(true);
}
// Check if debug mode
if ($key = array_search('--debug', $argv)) {
$app->setDebug(true);
//todo laster
// Ensure debug display even on fatal error
//register_shutdown_function([new Events\Cli\Debug(FALSE), 'display'], $app);
}
$app->setArgs($argv, $argc);
// Boom, Run
$app->run();
} catch (Exception $e) {
echo $e;
exit(255);
}
function d($object, $kill = true)
{
var_export($object);
if ($kill) {
exit;
}
}
/**
* Fix undefined function t when save object which is have method
* Validate in model
*
*/
function t($string)
{
//nothing
}