【发布时间】:2018-03-05 15:10:29
【问题描述】:
我想在 Twig 视图中显示 Symfony 3 中的当前路线。
我已经做了一些研究,但没有找到任何解决方案。我在 Twig 视图中尝试以下操作:
{{ app.request.uri }}
它返回类似:http://localhost:8000/_fragment?_path=_format%3Dhtml%26_locale%3Dfr%26_controller%3DFOSUserBundle%253ASecurity%253Alogin
{{ app.request.get('_route') }}
总是返回 NULL。
{{ app.request.getpathinfo }}
总是有:/_fragment
我需要的很简单。对于localhost:8000/article/5 之类的网址,我想检索/article/5。该怎么做?
【问题讨论】: