My application structure is:
.../www/console.php
.../www/apps/tasks/MainTask.php
.../www/apps/tasks/MonitoringTask.php
console.php code:
$loader = new \Phalcon\Loader();
$loader->registerDirs(array('apps/tasks/'))->register();
$di = new \Phalcon\DI\FactoryDefault\CLI();
$di->setShared('router', function() {
return new \Phalcon\CLI\Router();
});
$di->setShared('dispatcher', function() {
return new \Phalcon\CLI\Dispatcher();
});
$app = new \Phalcon\CLI\Console();
$app->setDI($di);
$app->handle($_SERVER['argv']);
MainTask.php
class MainTask extends \Phalcon\CLI\Task
{
public function mainAction()
{
print 'main_task main_action';
}
}
MonitoringTask.php
class MonitoringTask extends \Phalcon\CLI\Task
{
public function mainAction()
{
print 'monitoring_task main_action';
}
}
Problem is that when I call monitoring task from CMD
php console.php monitoring
MainTask mainAction always is executed. When i delete MainTask, I get this error
Phalcon\CLI\Dispatcher\Exception: MainTask handler class cannot be loaded
File=.....\www\console.php
Line=50
#0 [internal function]: Phalcon\CLI\Dispatcher->_throwDispatchException('MainTask handle...', 2)
#1 [internal function]: Phalcon\Dispatcher->dispatch()
#2 ...\www\console.php(50): Phalcon\CLI\Console->handle(Array)
#3 {main}
I don't understand why MonitoringTask is not found?