5

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.

madeye
  • 1,394
  • 2
  • 14
  • 29

1 Answers1

9

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.

madeye
  • 1,394
  • 2
  • 14
  • 29