symfony2如何从浏览器访问app / Resources / img? [英] symfony2 how to access app/Resources/img from browser?

查看:221
本文介绍了symfony2如何从浏览器访问app / Resources / img?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些项目特定的图像,我不想包含在任何捆绑中。我想让它们从树枝层进入。问题是:我如何发布它们(我既不能在web目录中看到符号链接,也不能在我的项目中看到资产配置)。任何提示都将受到赞赏。

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

我得到安装XxxBundle的资产为web / bundles / xxx ,但app / Resources目录没有任何变化。

I get Installing assets for XxxBundle into web/bundles/xxx, but nothing happens for the app/Resources directory.

推荐答案

如果你真的不想把它们放在一个包中,你可以直接将它们放在web目录中。例如。放置在 web / appImages / 中的 image.jpg 可以使用 img src显示在模板中=/ appImages / image.jpg/>

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" />.

尽管如此,Symfony方式鼓励您将所有内容保存在捆绑包中。如果您不希望将资源放在代码所在的特定捆绑包中,则可以专门为应用程序范围的资源创建一个单独的捆绑包。

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.

这篇关于symfony2如何从浏览器访问app / Resources / img?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆