title: Get image folder URI from controller and twig template
body: <p>I moved all the public images of my website to a folder out of the web folder of symfony so it can be shared with other web applications.
  I created a symbolic link to this folder so it can be accessed from the web folder of the symfony application.</p>
  
  <pre><code>ln -s /absolute/path/to/images /path/to/symfony/application_01/web/images
  ln -s /absolute/path/to/images /path/to/symfony/application_02/web/images
  </code></pre>
  
  <p>Etc... for all applications.</p>
  
  <p>I'm looking for a method that would allow me to retrieve the images URI in my development environment on localhost <strong>as well as</strong> in my production environment on the remote web server.</p>
  
  <p>I would like to be able to retrieve this URI from the twig template <strong>AND</strong> from the controller.</p>
  
  <p>Basically (for my application_01 for instance):</p>
  
  <p>In the <strong>development environment</strong> it would return:</p>
  
  <pre><code>http://localhost/images/my_image.jpg
  </code></pre>
  
  <p>In the <strong>production environment</strong>, it would return:</p>
  
  <pre><code>http://www.application_01.com/images/my_image.jpg
  </code></pre>
  
  <p>My problem is that I found lots of different ways to get URIs but I'm not totally clear about how Symfony manages them and what functions to use to have a global solution working in all cases.</p>
  
  <p>What is the best way to achieve my goal?</p>
  
  <hr>
  
  <p><strong>EDIT</strong></p>
  
  <p>Specifically I found some SO answers to quite similar questions proposing to use the following functions:</p>
  
  <p>$request->getScheme();
  $request->getHttpHost();</p>
  
  <p>That seems to correspond to the values or superglobals $_SERVER['REQUEST_SCHEME'] and $_SERVER['HTTP_HOST']</p>
  
  <p>And I don't know if this is the proper way to get this information since this is linked to the current request received by the server.</p>
  
  <p>Isn't there another way to get this info independently from the request currently processed by the server?</p>