Hi symfonians ! ^^

Considering the following URL:

http://dev.col.com/app_dev.php/my-route?bar=1&foo=bar


Here are the results of the different main public methods of the Symfony\Component\HttpFoundation\Request class about the URL and server analysis: (calls are made inside a basic controller class)

$r = $this->getRequest();
$r->getClientIp()	127.0.0.1
$r->getScriptName()	/app_dev.php
$r->getPathInfo()	/my-route
$r->getBasePath()	''
$r->getBaseUrl()	/app_dev.php
$r->getScheme()		http
$r->getPort()		80
$r->getHttpHost()	dev.col.com
$r->getRequestUri()	/app_dev.php/my-route?bar=1&foo=bar
$r->getUri()		http://dev.col.com/app_dev.php/my-route?bar=1&foo=bar
$r->getUriForPath("/other-path") http://dev.col.com/app_dev.php/other-path
$r->getQueryString()	bar=1&foo=bar
$r->isSecure()		false
$r->getHost()		dev.col.com
$r->getMethod()		GET
$r->isXmlHttpRequest()	false


I have submitted a small PR to the git main Symfony2 repository to have a new function that I need in one of my sf2 projects. If your are interested in this PR, feel free to add a comment :) :

$r->getBaseServerUrl()	http://dev.col.com


It was to avoid the following Twig code:


See you. COil :)

PS: Note that the getBasePath() function returns an empty string as the root of the virtual host is set to the /web folder of the application, for an URL like http://dev.col.com/web/app_dev.php/my-route?bar=1&foo=bar it would return /web.

PS2: If you want real Symfony cheatsheet, check the blog of Andréia Bohner.

PS3: My PR was useful !! :)