问题
I've got some project specific images that I don't want to include in any bundle. I'd like to have them accessible from twig layer. The question is: how can I publish them (I can see neither symlinks in web directory nor assetic config in my project). Any hint will be appreciated.
edit: When I run
php app/console assets:install help
I get Installing assets for XxxBundle into web/bundles/xxx
, but nothing happens for the app/Resources directory.
回答1:
If you really don't want to put them in a bundle you can just place them directly in the web directory. E.g. image.jpg
placed in web/appImages/
can be displayed in a template using img src="/appImages/image.jpg" />
.
Nevertheless "the Symfony way" encourages you to keep everything within bundles. If you don't want to have the Resources in one specific bundle where your code lives you can have a separate bundle specifically for the application-wide resources.
回答2:
You can publish items in the app/Resources/img by doing:
php app/console assetic:dump --env=prod --no-debug
from the root of the project.
That is where you place system wide libraries.
来源:https://stackoverflow.com/questions/14982476/symfony2-how-to-access-app-resources-img-from-browser