【发布时间】:2016-04-07 17:16:00
【问题描述】:
我如何在Slim 3 routes 中有或选项?
例如,这是我目前所做的:
// Home page.
$app->get('/', function (Request $request, Response $response, array $args) {
// Get the application settings.
$settings = $this->get('settings');
// Check if the home page class is provided.
... lots of codes
});
$app->get('/home', function (Request $request, Response $response, array $args) {
// Get the application settings.
$settings = $this->get('settings');
// Check if the home page class is provided.
... lots of codes
});
除了重复这些代码块,我可以把它们变成一个像:
$app->get('/ or /home', function (Request $request, Response $response, array $args) {
...}
【问题讨论】:
-
optional segments不是你想要的吗?
-
是的!谢谢!
-
@EvgenySoynov 请添加您的评论作为答案。然后OP可以接受它。