Example #1
0
$config = $configPath . 'config.php';
$autoLoad = $configPath . 'autoload-cli.php';
try {
    $app = new Application\Cli();
    // Record any php warnings/errors
    set_error_handler(['Utilities\\Debugcli\\PhpError', 'errorHandler']);
    $app->setAutoload($autoLoad, $appDir);
    $app->setConfig($config);
    // 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);
        // Ensure debug display even on fatal error
        register_shutdown_function([new Events\Cli\Debug(FALSE), 'display'], $app);
    }
    $app->setArgs($argv, $argc);
    //  Run
    $app->run();
} catch (Exception $e) {
    echo $e;
    exit(255);
}