I haven't been able to find any examples of what I'm looking to do... I'm fairly familiar with the MVC routing, but this has me baffled.
cli.php
<?php
$di = new Phalcon\Di\FactoryDefault\Cli();
$loader = new Phalcon\Loader();
$loader->registerDirs(array(
__DIR__ . "/tasks",
));
$loader->register();
$console = new Phalcon\Cli\Console();
$di->setShared('router', function() {
$router = new \Phalcon\Cli\Router();
$router->add("/:task/:action/params", array(
'task' => 1,
'action' => 2,
'params' => 3
));
return $router;
});
$console->setDI($di);
try {
$console->handle($_SERVER['argv']);
} catch (Exception $e) {
$exceptionLogger = new Phalcon\Logger\Adapter\Stream('php://stdout');
$exceptionLogger->critical($e->getMessage() . $e->getTraceAsString());
}
tasks/MainTask.php
<?php
class MainTask extends AbstractTask {
public function testAction() {
echo "Yay!\n"
}
}
[email protected]:~/code/cli-proj/app$ php cli.php main test
[Mon, 10 Apr 17 17:38:34 -0400][CRITICAL] Action 'main' was not found on handler 'main'#0 [internal function]: Phalcon\Cli\Dispatcher->_throwDispatchException('Action 'main' w...', 5)
#1 [internal function]: Phalcon\Dispatcher->_dispatch()
#2 [internal function]: Phalcon\Dispatcher->dispatch()
#3 /home/eellis/code/php/bones/cli.php(20): Phalcon\Cli\Console->handle(Array)
#4 {main}
[email protected]:~/code/cli-proj/app$