我配置了这两条路线
$app->match ( '/controller/param/{country}/{q}', "demo.controller:demoAction" )->value ( 'country', 'de' )->value('q', '')->bind ( 'demo_action_with_country' );
$app->match ( '/controller/param/{q}', "demo.controller:demoAction" )->value ( 'q', '' )->bind ( 'demo_action_without_country' );
然而 - 这不起作用。如果我呼叫/controller/param/Test-String
路由匹配并返回内容。如果我打电话给/controller/param/DE/Test-String
,我会得到 NotFoundHttpException
我该如何解决这个问题?
答案 0 :(得分:6)
好的,我可以通过我自己轻松解决这个问题。这是我的解决方案:
$app->match ( '/controller/param/{q}', "demo.controller:demoAction" )->value ( 'q', false )->bind ( 'demo_action_without_country' );
$app->match ( '/controller/param/{country}/{q}', "demo.controller:demoAction" )->value ( 'country', false )->value('q', '')->bind ( 'demo_action_with_country' );