function run_cli_application($argv) { $di = get_app_di(); $application = new \Phalcon\Cli\Console($di); $application->handle(get_cli_arguments($argv)); }
$di->setShared("dispatcher", function () { $dispatcher = new \Phalcon\Cli\Dispatcher(); $dispatcher->setDefaultNamespace("PhalconDocs\\Task"); return $dispatcher; }); // Create a console application $console = new \Phalcon\Cli\Console(); $console->setDI($di); /** * Process the console arguments */ $arguments = []; foreach ($argv as $k => $arg) { if ($k == 1) { $arguments["task"] = $arg; } elseif ($k == 2) { $arguments["action"] = $arg; } elseif ($k >= 3) { $arguments["params"][] = $arg; } } try { // Handle incoming arguments $console->handle($arguments); } catch (\Throwable $throwable) { fwrite(STDERR, "ERROR: " . $throwable->getMessage() . PHP_EOL); exit(1); } catch (\Exception $exception) { fwrite(STDERR, "ERROR: " . $exception->getMessage() . PHP_EOL); exit(1); }