PHP-DI:路线和可选航段
PHP-DI: Routes and optional segments
我正在使用 PHP-DI 和 Slim 框架。在 Slim 中,您可以通过在其周围放置方括号来使路由段成为可选的。现在我已经设置了 PHP-DI 当我省略了可选的路线段时,我得到了这个错误:
Type: Invoker\Exception\NotEnoughParametersException
Message: Unable to invoke the callable because no value was given for parameter 1 ($limit)
这是我的路线:
$app->get('/api2/products[/{limit}]', ['\App\Controllers\SampleProductController', 'show']);
我在 PHP-DI 文档中找不到任何关于可选部分的内容,只是如何获取命名段的值。
我正在使用 PHP-DI 和 Slim 框架。在 Slim 中,您可以通过在其周围放置方括号来使路由段成为可选的。现在我已经设置了 PHP-DI 当我省略了可选的路线段时,我得到了这个错误:
Type: Invoker\Exception\NotEnoughParametersException
Message: Unable to invoke the callable because no value was given for parameter 1 ($limit)
这是我的路线:
$app->get('/api2/products[/{limit}]', ['\App\Controllers\SampleProductController', 'show']);
我在 PHP-DI 文档中找不到任何关于可选部分的内容,只是如何获取命名段的值。