我想配置 Symfonylocale
选项,以便我可以成功访问以下路由:
/route
/{locale}/route
目前,我可以访问/{locale}/route
并获得我的视图,但是,/route
返回一个No route found for "GET /route"
. 我的配置如下:
#app/config/parameters.yml
parameters:
locale: en
#app/config/config.yml
parameters:
app_locales: en|fr
framework:
translator: { fallback: "%locale%" }
default_locale: "%locale%"
#app/config/routing.yml
app:
resource: '@AppBundle/Controller/'
type: annotation
我的控制器有以下注释:
#src/AppBundle/Controller/Admin/MyController.php
/**
*
* @Route(
* "/{_locale}/admin/my",
* defaults={"_locale":"%locale%"},
* requirements={"_locale":"%app_locales%"}
* )
*/
class MyController extends Controller
{
/**
* @Route("/", name="admin_my_list")
* @Method("GET")
*/
public function listAction()
{
...
}
}
如果我特别包含locale
,一切正常。如果我排除locale
,我会收到No route found
错误消息。