【发布时间】:2013-06-12 06:08:50
【问题描述】:
我有一个关于 symfony2 和 bootstrap 的问题。我不明白为什么我可以从环境“prod”而不是从环境“dev”加载图标图像。在开发中,我收到此错误。
路由是“GET /img/glyphicons-halflings.png”。
图像 web/img/glyphicons-halflings.png 是指向 ../../vendor/twitter/bootstrap/img/glyphicons-halflings.png 的符号链接
我收到此错误
http://my.web.site/app_dev.php/img/glyphicons-halflings.png
并使用
获取图像http://my.web.site/img/glyphicons-halflings.png
更新
我以这种方式包含引导程序:
{% stylesheets '%kernel.root_dir%/../vendor/twitter/bootstrap/less/bootstrap.less' %}
<link rel="stylesheet" type="text/css" href="{{ asset_url }}" />
{% endstylesheets %}
当我在 prod 中使用时,这是可行的
<span class="icon-edit"></span>
我有这个资产配置:
assetic:
debug: %kernel.debug%
use_controller: false
bundles: [ MyAwesomeBundle ]
filters:
lessphp:
file: %kernel.root_dir%/../vendor/leafo/lessphp/lessc.inc.php
apply_to: "\.less$"
我也尝试过创建我的收藏:
assetic:
assets:
senso:
inputs:
- '../img/glyphicons-halflings.png'
outputs:
- 'img/glyphicons-halflings.png'
filters:
- ?lessphp
:dump create web/assetic/senso.png 和 web/assetic/senso_glyphicons-halflings.png 但是,...如何使用 senso*.png 图像?
【问题讨论】:
-
遗憾的是,您不能对图像使用 * 语法...而且您应该完全省略图像上的 lessphp :) ?告诉assetic仅在生产中应用过滤器。
-
您在集合中的输入图像最好类似于“%kernel.root_dir%/../vendor/twitter/bootstrap” - 请参阅我的回答,我已经为您包含了我的资产配置。
-
现在可以使用,但使用资产('css/bootstrap.css')而不是资产('@css_bootstrap')。使用 @css_bootstrap 资产只需编写 /css_bootstrap。但是......现在它可以工作了!!!
-
使用 {% stylesheet ... 我收到此错误:[2/2] Twig_Error_Runtime: 在模板编译期间引发异常(“没有“css_boostrap”资产。”)在“SensorarioTrashwareBundle:Default:layout.html.twig”中。
-
我会再次检查并更新答案。 @syntax 可用于引用集合名称。您是否可能重命名了assetic.assets 下的集合?
标签: symfony twitter-bootstrap get glyphicons