-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathcli
54 lines (44 loc) · 1.42 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
#!/usr/bin/env php
<?php
/**
* A CLI launcher and a CLI script that launches Phalcon tasks
*
* @example cli [task] [action] [param1 [param2 ...]]
* @example cli Example index
* @example cli Example index --debug --single --no-record
*/
use Phanbook\Common\Console;
use Phanbook\Tools\Cli\PhpError;
// Register The Auto Loader
require __DIR__ . '/bootstrap/autoloader.php';
date_default_timezone_set('UTC');
// Capture runtime errors
register_shutdown_function([PhpError::class, 'runtimeShutdown']);
try {
$app = new Console();
// Record any php warnings/errors
set_error_handler([PhpError::class, '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: later
// 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) {
fwrite(STDERR, $e->getMessage() . PHP_EOL);
exit(1);
}