How to get the absolute path of a file in a Symfony2 controller?
<p>I want to send an email with an attachement so therefore I need the absolute path to the pdf file. </p>

<p>I tried the flowing code in the controller:</p>

<pre><code>$this-&gt;get('templating.helper.assets')-&gt;getUrl('MyDoc.pdf', 'doc');
</code></pre>

<p>But this returns:</p>

<pre><code>/bundles/MyBundle/doc/MyDoc.pdf?v=1
</code></pre>

<p>This is the path without the domain for web access. But I need the real path starting the root of the disk, like example below. How is this possible? Thanks.</p>

<pre><code>/home/MyAccount/public_html/web/src/company/MyBundle/Resources/public/doc/MyDoc.pdf
</code></pre>