Mandatory Value Parameters can not be parsed
I tried to create a route where a group of Value Parameters is mandatory like this example:
<?php
return [
// ....
'console-export-prepared-products' => [
'options' => [
'route' => 'export prepared products (--from-file=|--model=)',
'defaults' => [
'controller' => \Controller\PreparedProductsController::class,
'action' => 'export',
'verbose' => false,
]
]
],
//...
];
But this results into a InvalidArgumentException:
Fatal error: Uncaught exception 'Zend\Console\Exception\InvalidArgumentException' with message 'Cannot understand Console route at "(--from-file=|--model=)"' in /var/www/mw/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php on line 946 Zend\Console\Exception\InvalidArgumentException: Cannot understand Console route at "(--from-file=|--model=|--recent)" in /var/www/mw/vendor/zendframework/zendframework/library/Zend/Console/RouteMatcher/DefaultRouteMatcher.php on line 432
I expected that the route is only matched if either the parameter --from-file or --model is set.
At this moment zend-console does not support "alternative parameters". You can only use literal alternative:
( foo | bar )
or flag alternative:
( -x | -c )
I can't promise anything, but I'll try to look into this in coming few days.
As a workaround i use a route definition like this:
[--from-file=] [--model=]
And in my controller is a validation for the parameters executed.
This repository has been closed and moved to laminas/laminas-console; a new issue has been opened at https://github.com/laminas/laminas-console/issues/2.