CLI loads only MainTask class mainAction method

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?



90.5k

What phalcon version are you using?



13.9k

I tested with 1.0.1 and 1.1Beta 3.



13.9k

Don't work on 1.1 version too. It seems that $app->handle($_SERVER['argv']); don't process passed parameters. I tried to pass there array with different values and in all cases it loads only MainTask.php. Please help, I'am stuck with my project because of that :(

I think the bug is here:

$loader->registerDirs(array('apps/tasks/'))->register();

change it to:

$loader->registerDirs(array('FULL_PATH_TO_apps/tasks/'))->register();


13.9k

No, full path to apps/tasks don't help

it seems that 1.1.0 has new CLI params format: https://github.com/phalcon/cphalcon/issues/601



13.9k

Thank You - now it works. It would be great that for every new version developers could see upgrade guide, for example this issue was important when updated phalcon from 1.0 to 1.1, maybe it could be similar like Zend Framework http://framework.zend.com/manual/1.12/en/migration.html



2.9k

I'm confused about how to actually go about changing what is above so it will work, any clues anyone?

Same here. Any proper info anywhere?