Internet

Get Symfony web root Url without Script name

July 22, 2011 by Sarath DR in Internet, Web Development with 1 Comment

I had a requirement to access an image inside a folder in the web root folder in symfony. I came across a solution but I am not sure this is the only way to get the url to path. Please add a comment if you have any other solution.

For example, Let your path to the web folder be “project/trunk/web”. The following code will output  ”project/trunk/web”

sfContext::getInstance()->getRequest()->getRelativeUrlRoot();

You will get the base url by

sfContext::getInstance()->getRequest()->getUriPrefix();

You can concatenate both string to get the result.

http:://localhost/project/trunk/web

Tagged , , , ,

Share this to

Related Posts

One Comment

  1. WillianMay 4, 2012 at 8:59 pmReply

    Thanks very much.

    Works for me!

    I’m using Symfony 1.0.22-LAST

Leave a reply

Your email address will not be published. Required fields are marked *

*

About
View Sarath D R's profile on LinkedIn

I am a technology consultant and an entrepreneur focused on the following technologies Java,Spring, Android, Angular, Asterisk, Symfony, Cake , Code-Igniter, Jquery , XAMPP, XHTML, AJAX, MySql, Seo, Web Design, Wordpress, iPhone development.

Today’s Tips
  • Generate Codova.jar file from Phonegap project using ant
  • Google map javascript client  to find the geographic co-ordinates  from  Address or post code
  • Update Android main UI from Webview – Phonegap Plugin
  • Jplayer is not working  with HTC One Android 4.3 version browser
  • Regular expression to validate mobile phone numbers starting with + ( plus ) – php
  • Simple pagination script for PHP
  • Useful adb ( Android Debug Bridge ) commands
  • Change the javascript files url to absolute url – Symfony 1.4
  • Set Http authentication header from Client – PHP / CURL

This site uses cookies from Google to deliver its services, to personalise ads and to analyse traffic. Information about your use of this site is shared with Google. By using this site, you agree to its use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.This site also uses cookies from Google to deliver its services, to personalise ads and to analyse traffic. Information about your use of this site is shared with Google. By using this site, you agree to its use of cookies.

Close