Reputation: 8500
I'm googling and googling and can't find what I need.
How to get path to "web" directory in symfony2 in
action [no idea, i only found solution for older versions of symfony:
$sf_relative_url_root = sfContext::getInstance()->getRequest()->getRelativeUrlRoot();
I've tried also $this->get('security.context')->getRequest()->getRelativeUrlRoot(), but it doesn't work]
.js file
In case of .js file I do for now in twig template something like that:
<script type="text/javascript">
var asset_url="{{asset(' ')}}";
asset_url = asset_url.substr(0, asset_url.length-1);
</script>
<script href="{{asset('js/script.js')}}" type="text/javascript"></script>
is a better way?
Upvotes: 0
Views: 3114
Reputation: 8425
If I understood your question correctly, then what you're looking for is $this->getRequest()->getUri()
in a controller class.
Take a look at Symfony\Component\HttpFoundation\Request
class if it's not, you will most likely find it there.
Upvotes: 1