As a matter of fact, there is a service you could use for this, the kernel ($this->get('kernel')
). It has a method called locateResource()
.
For example:
$kernel = $container->getService('kernel');
$path = $kernel->locateResource('@AdmeDemoBundle/path/to/file/Foo.txt');