How to get the path of the request in symfony2

你离开我真会死。 提交于 2019-12-07 02:49:09

问题


I know of the method \Symfony\Component\HttpFoundation\Request::getPathInfo() however in the docs it states that, that only returns the path of the request which is "relative" to the "executed script".How can I get the full path?and on a second note what does 'executed script' mean when all requests are going through the front controller?


回答1:


$request->getUri() returns the absolute URL => http://example.com/app.php/path

$request->getRequestUri() returns the absolute path => /app.php/path

$request->getPathInfo() returns the path corresponding to your controller's action => /path

getPathInfo just subtracts the executed script (/app.php) from the request URI, so it returns the path relative to the executed script.



来源:https://stackoverflow.com/questions/25601869/how-to-get-the-path-of-the-request-in-symfony2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!