Symfony 2 - accessing government assets directly
I have a folder called "cdn" in my / web folder and I would like to give public access to the javascript file there (it is basically a bookmarklet). I don't want to use a controller to work with the file, but let the server serve the file directly.
How can I do this in Symfony 2? (PS I 'also uses assetic)
Thank you in advance, Romny
source to share
You can use a different directory by specifying the root of your shared folder using assets_base_urls
in your configuration:
app/config/config.yml:
templating:
assets_base_urls: "%assets_base_urls%"
This will use the value defined in certain contexts:
app/config/config_dev.yml:
parameters:
assets_base_urls: "http://localhost/.../cdn/"
app/config/config_prod.yml:
parameters:
assets_base_urls: "http://cdn.example.com/"
This url should point to a directory on your server eg. /var/www/site/public/
...
You need to dump assets to the appropriate directories in both contexts to put the files in the correct directory:
# dev
php app/console assetic:dump --env=dev .../cdn --no-debug
# prod
php app/console assetic:dump --env=prod `/var/www/site/public/` --no-debug
source to share