symfony2 how to access app/Resources/img from browser?

安稳与你 提交于 2020-01-05 07:34:29

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!