In Symfony2 how to use basic assets system for including misc downloads, files, videos, etc

StackOverflow https://stackoverflow.com/questions/23282203

  •  09-07-2023
  •  | 
  •  

Question

This should be simple, but it doesn't appear to be documented anywhere.

I need to include some misc downloads and videos in a project. Best practice seems to be including these files in my bundle/Resources/public/ folder, such as bundle/Resources/public/downloads/download.zip.

Assetic is great for dealing with images, css and js files...but for these misc files, I'm not sure what to do.

If I put them in the public subfolder of my bundles folder, and run app/console assets:install --symlink, i can see that it is linked to from my /web/bundles folder...but if I add a link to it like this:

 {{ asset('downloads/download.zip') }}

it doesn't work, even though it sounds like it should as described here: Difference between assetic:dump and assets:install

Am I supposed to do a link like this?:

{{ asset('bundles/mybundle/downloads/download.zip') }}

or am I doing something else wrong?

Thank you!

Was it helpful?

Solution

As @Wouter J already mentioned (very short), you must always reference all assets from the root of the web directory. That's how I've got to do it anyway to get it working. Talking from personal experience :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top