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');
More Related Contents:
- do not include AcmeDemoBundle using symfony installer
- How to get the value from and save to Database in php
- Symfony 3, Guard & Handlers
- Creating sign-in with my site functionality
- Is there a built-in way to get all of the changed/updated fields in a Doctrine 2 entity
- How to access dynamic variable names in twig?
- Docker in MacOs is very slow
- Path of assets in CSS files in Symfony 2
- Symfony2 conceptual issue: general bundles vs. specific ones
- Symfony2 – Force file download
- Symfony 3.4 Use view inside my bundle
- Symfony: Clear doctrine cache
- Use Javascript to access a variable passed through Twig
- Request headers bag is missing Authorization header in Symfony 2?
- How to access an application parameters from a service?
- Injecting SecurityContext into a Listener prePersist or preUpdate in Symfony2 to get User in a createdBy or updatedBy Causes Circular Reference Error
- Symfony2, Dynamic DB Connection/Early override of Doctrine Service
- How to cache in Symfony 2?
- How to set a class attribute to a Symfony2 form input
- What is the best way to notify a user after an access_control rule redirects?
- How to setup table prefix in symfony2
- PDOException “could not find driver” in php
- How to customize FOS UserBundle URLs
- How to inject a repository into a service in Symfony?
- How to get the server path to the web directory in Symfony2 from inside the controller?
- Remove / Replace the username field with email using FOSUserBundle in Symfony2 / Symfony3
- Symfony 2 load different template depending on user agent properties
- Symfony: How do I refresh the authenticated user from the database?
- Use custom delimiters in the current Twig template
- How to access a different controller from inside a controller Symfony2