Reputation: 381
I'm trying to access a function from my controller, using the console. It's a small application, so i only have one controller, 'IndexController'. The action i'm trying to reach is the 'buildSchemeAction'.
As i understand, you have to add routes in your "module.config.php" file, which i did as followed :
return array(
'console' => array (
'router' => array (
'routes' => array (
'build-scheme' => array (
'options' => array (
'route' => 'build-scheme',
'defaults' => array (
'controller' => 'Application\Controller\Index',
'action' => 'build-scheme'
)
)
)
)
)
), ..//
My Controller function looks like this :
public function buildSchemeAction()
{
// logic here
}
When i enter the following in console :
php index.php build-scheme
i get :
Zend Framework 2.2.5 application
Usage:
Reason for failure: Invalid arguments or no arguments provided
I've been searching the web, but can't find anything. Am i missing something?
Upvotes: 2
Views: 3635
Reputation: 381
I just found out why it didn't work. I had my console routes at the top of my module.config file, while this was at the very bottom :
// Placeholder for console routes
'console' => array(
'router' => array(
'routes' => array(
../
),
),
),
Totally overlooked it, since it was there by default.
Upvotes: 9