示例#1
0
/**
 * Report errors, since we're in CLI.
 * Note that log_errors = 1, which outputs to STDERR. display_errors however outputs to STDOUT.
 * In a CLI environment this results in a double error. display_errors is therefore set to 0
 * so that STDERR is the only stream showing errors.
 *
 * @see http://stackoverflow.com/questions/9001911/why-are-php-errors-printed-twice
 */
error_reporting(-1);
ini_set('log_errors', 0);
ini_set('display_startup_errors', 1);
ini_set('display_errors', 'stderr');
/**
 * Process the command
 */
$args = Garp_Cli::parseArgs($_SERVER['argv']);
if (empty($args[0])) {
    Garp_Cli::errorOut('No command given.');
    Garp_Cli::errorOut('Usage: g <command> [args,..]');
    // @codingStandardsIgnoreStart
    exit(1);
    // @codingStandardsIgnoreEnd
}
/* Construct command classname */
$classArgument = ucfirst($args[0]);
$namespaces = array('App', 'Garp');
$config = Zend_Registry::get('config');
if (!empty($config->cli->namespaces)) {
    $namespaces = $config->cli->namespaces->toArray();
}
$commandNames = array_map(function ($ns) use($classArgument) {