I'm working on an Apigility application, so far so good. It works perfectly with http to serve as an API for a web frontend application. Now, I'm trying to implement scheduled cron operations through console routing. But no matter what I tried, I can't get it to work...
At first, I simply added this in my module configuration :
'console' => [
'router' => [
'routes' => [
'test_route' => [
'options' => [
'route' => '/test',
'defaults' => [
'controller' => 'mymodule\V1\Console\Test\Controller',
'action' => 'test'
],
],
],
],
],
],
Then trying to call with :
php ./public/index.php /test
The result was "No base path provided". So I added this in my module configuration :
'view_manager' => [
'base_path' => __DIR__ . '/../',
]
Now, no matter what I try, I always get a 404 "The requested URL could not be matched by routing.". I found examples over the internet running commands like "zf foo bar" to run a zend application as command line, but I don't have that command on my (Windows 8.1) system. Should I install this ? I'm using composer, and I tried to install various packages like zfcampus/zf-console or zendframework/zend-console, but without any noticeable changes...
I'm new with Apigility but with Zend as well... So my main issue I suppose is that I have no idea if my problem comes from one or the other...
As on some other place I received the answer that my routing was wrong without real intel about why and how it was wrong, I add here a few other examples I tried, some takend from the documentation available.
I'm trying another example :
module.config.php
'console' =>[
'router' => [
'routes' => [
'console.foo' => [
'options' => [
'route' => 'delete user <userEmail>',
'defaults' => [
'controller' => 'Application\Controller\Index',
'action' => 'password'
],
],
],
],
],
],
then I call :
php ./public/index.php delete user ti@ad.com
I still get exactly the same "URL could not be matched by routing" error....
Right now I'm trying to deploy the app on a linux server, I think maybe its related to my windows machine ?
I also tried these routes :
'console' =>[
'router' => [
'routes' => [
'console.foo' => [
'options' => [
'route' => 'delete user <userEmail>',
'defaults' => [
'controller' => 'Application\Controller\Index',
'action' => 'password'
],
],
],
'console.foo2' => [
'options' => [
'route' => 'test',
'defaults' => [
'controller' => 'Application\Controller\Index',
'action' => 'password'
],
],
],
'console.foo3' => [
'options' => [
'defaults' => [
'controller' => 'Application\Controller\Index',
'action' => 'password'
],
],
],
'console.foo4' => [
'route' => 'test',
],
'console.foo5' => [
],
'console.foo6' => [
'type' => 'catchall'
],
],
],
],
And I tried of course different associated command, with parameters, without...
php ./public/index.php test
php ./public/index.php
php ./public/index.php delete user test@dom.aine
No matter what I do, I always get the same "URL not matching any route" response.... And apparently not related to my machine, same on my linux server
Just to emphasis one thing, I really get a 404 displayed in the console (the HTML code response being displayed). Maybe it's not detecting it runs in console ??