We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

CLI loads only MainTask class mainAction method

My application structure is:


console.php code:

$loader = new \Phalcon\Loader();
$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();


class MainTask extends \Phalcon\CLI\Task
    public function mainAction()
        print 'main_task main_action';


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
#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?


What phalcon version are you using?


I tested with 1.0.1 and 1.1Beta 3.


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:


change it to:



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


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


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?