If your folder is web-accessible (i.e. you can type the url http://localhost/web/uploads/test.txt
in your address bar and download the file), all you have to do is map the route gaufrette_download
to that path. Your bundle's routing.yml
could look like this (notice the missing defaults: { controller: ... }
):
gaufrette_download:
path: /web/uploads/{file}
If your .htaccess
is defined properly your web server should serve the file instead of accessing your application. You might have to add requirements for file
, e.g. to allow for slashes (search the symfony cookbook for this)
If you just want to skip writing a controller (action), you could just as well create an event listener which is triggered when your request matches the route.