Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Console route in Zend3 is not matching

I have a console route in my module.config.php file

'console' => [
        'router' => [
            'routes' => [
                'remove' => [
                    'type'    => 'simple',
                    'options' => [
                        'route'    => 'remove [force] [init]',
                        'defaults' => [
                            'controller' => Controller\CliController::class,
                            'action'     => 'remove',
                        ],
                    ],
                ]
            ]
        ]
    ]

And my Controller that has method removeAction()

namespace Controller;

class CliController extends AbstractActionController
{
    public function removeAction()
    {
        $this->logger->debug('I am in');
    }
}

When i do command php public/index.php remove force or php public/index.php remove I never get sent to do controller and there is no error or any output. So am I doing the matching wrong?

It's like app is not realizing it was called from terminal. Sometimes it just returns html if i remove getConfig method from Module.php within my module/MyModulefolder.

like image 826
madeye Avatar asked Sep 06 '16 07:09

madeye


1 Answers

The problem was that i didn't include 'Zend\Mvc\Console' in modules.config.php so that's way it wasn't reacting when it was given a command from console.

After putting this into array in modules.config.php everything is working.

Rookie mistake.

like image 200
madeye Avatar answered Nov 18 '22 06:11

madeye