Symfony 2.8 - 从视图访问(本地)JSON?

I have a symfony2 app with a couple of bundles and assetic which handles my css and js.

I would like to also deploy a dataset which the view will need to draw a map - let's call it map.json.

Where should I put this file so I can access it with relative ease from a view (twig template) or other javascript file?


EDIT: In one of the controllers (written a couple years ago...) I retrieved a JSON document as follows:

$myFile = $this->get('kernel')->getRootDir() . '/../web/common/path/to/file.json';
$parameters['myFile'] = file_get_contents($myFile);

And then returned $parameters with the view. It works, but seems a bit strange... and it doesn't help me if I need to access the file from an external javascript file (eg. myJs.js).

I also don't particularly like having to hardcode asset paths, especially if I also have to do it to access it via external javascript.

The location of your json-file must be owned by www-data user and not be blocked by .htaccess so you either put it into the web folder, or put it in one of your bundles Resources/public folders which are simlinked to your webfolder.