I use annotations router in web application and it works great. My configurations looks like:
$di->setShared('router', function () {
$router = new RouterAnnotations(false);
$router->addModuleResource('company', 'Modules\Company\Controllers\Auth');
$router->addModuleResource('company', 'Modules\Company\Controllers\Index');
$router->addModuleResource('company', 'Modules\Company\Controllers\Error');
})
And I generate URL with:
$this->url->get(['for' => 'company.index.index'])
However there is problem with annotations router in CLI tasks, because routes are registered only in web DI, so i copied router service to cli DI. But i got an error:
Parameter 'uri' must be a string
in line
$console->handle($arguments);
when i run a CLI app.
The question is: how can I get access to all routes in annotations router in a CLI app. I can rewrite them to static config, but it is ugly and unprofessional.