I am new in symfony2. i am stuck at small problem. my directory path is like this
project
/app
/bin
/src
/neil
/mybundle
/Controller
/DependencyInjection
/EventListner
/Helper
/Resources
/public
/js
/script.js
/Services
/Test
/vendor
/web
I want to access the url of script.js in my controller/services(not in template). How would i do it.
edit: I have tried
$fileLocator = $this->container->get('file_locator');
$path = $fileLocator->locate('@neilmybundle/Resources/public/js/script.js');
It returns directory path. If i use this directory path like
$r = '<script type="text/javascript" src="'.$path.'"></script>';
return new Response($r);
It does not source the file.