Often you need to get the absolute URL of the site to insert a link into an email or something similar.
This becomes annoying in a large environment where there are multiple copies of the site (dev, staging etc) all with different urls. While you could easily create it using the $_SERVER array, or store the full url in the app.yml (meaning you have to change it for each copy of the site), this method is much easier.
eg to generate the link to forgot password page you would do:
<?php $url = url_for("@forgot_pass", true); ?>
That second parameter “true” tells it return the absolute path. Whats nice is that it includes the controller aswell (eg frontend_dev.php), which makes testing easier.
Remember, you’ll need to load the Url helper to use this function. From the action or model it can be done like this:
sfLoader::loadHelpers(array('Url'));