我想建立一个网站,我正在共享主机和所有工作正常但FontAwesome图标,因为Symfony没有找到他们应该在哪里。我按照这个步骤来移动网站制作共享主机:Fontawesome字体失败后资产:安装和资产:转储
- 发布资产作为硬拷贝,因为SH不允许符号链接,所以我运行此命令
assets:install
- 通过运行这个命令发布由Assetic处理资产:
assetic:dump
(DEV)和assetic:dump --env=prod
(正式版)
但它不工作,因为我得到这个错误在Firebug的所有时间:
"NetworkError: 404 Not Found - http://tanane.com/bundles/backend/img/mybg.png"
"NetworkError: 404 Not Found - http://tanane.com/bundles/backend/fonts/fontawesome-webfont.woff?v=4.1.0"
"NetworkError: 404 Not Found - http://tanane.com/bundles/backend/fonts/fontawesome-webfont.ttf?v=4.1.0"
在本地主机上,按照相同的步骤,工作正常,所以我不知道是否是权限问题或其他问题。
这是我在base.html.twig
定义资产:
{% block stylesheets %}
{% stylesheets
'bundles/template/css/bootstrap.min.css'
'bundles/template/css/bootstrap-theme.min.css'
'bundles/template/css/font-awesome.min.css'
'bundles/template/css/select2.css'
'bundles/template/css/select2-bootstrap.css'
'bundles/template/css/bootstrapValidator.min.css'
'bundles/template/css/datepicker.css'
'bundles/template/css/datepicker3.css'
'bundles/template/css/tanane.css'
filter='cssrewrite'
%}
<link rel="stylesheet" href="{{ asset_url }}" />
{% endstylesheets %}
{% endblock %}
我做了一个调查,发现很多话题围绕这一问题,例如this one我也发现this interesting one但有我周围的第二个疑虑。
可以给我一个帮助吗?我stucked
安装SpBowerBundle + FkrCssURLRewriteBundle
我已经安装并配置了捆绑,但即使以后我仍然有在这种情况下与图像有关的问题,只是在选择二库。
这是bower.json
文件内容:
{
"name": "TemplateBundle",
"dependencies": {
"bootstrap": "latest",
"bootstrap-datepicker": "latest",
"bootstrap-growl": "latest",
"bootstrapvalidator": "latest",
"jquery": "1.11.*",
"jquery-migrate": "latest",
"pwstrength-bootstrap": "latest",
"select2": "latest",
"font-awesome": "latest"
}
}
这是我加入到/app/config/config.yml
#FkrCssURLRewriteBundle
fkr_css_url_rewrite:
rewrite_only_if_file_exists: true
clear_urls: true
# SpBowerBundle
sp_bower:
install_on_warmup: true
allow_root: true
assetic:
enabled: true
nest_dependencies: false
filters:
packages:
bootstrap:
css:
- css_url_rewrite
font_awesome:
css:
- css_url_rewrite
bundles:
TemplateBundle: ~
这行,现在我得到的错误:
"NetworkError: 404 Not Found - http://tanane.dev/select2.png"
"NetworkError: 404 Not Found - http://tanane.dev/select2-spinner.gif"
为什么?
残疾人Assetic在SpBowerBundle
我在SpBowerBundle禁用assetic在/app/config/config.yml
:
# SpBowerBundle
sp_bower:
install_on_warmup: true
allow_root: true
bundles:
TemplateBundle: ~
由于我使用assetic也SpBowerBundle处理库的依赖关系,然后我重写CSS/JS块在base.html.twig
如下:
{% stylesheets
'bundles/template/components/bootstrap/dist/css/bootstrap.min.css'
'bundles/template/components/bootstrap/dist/css/bootstrap-theme.min.css'
'bundles/template/components/font-awesome/css/font-awesome.min.css'
'bundles/template/components/select2/select2.css'
'bundles/template/css/select2-bootstrap.css'
'bundles/template/components/bootstrapvalidator/dist/css/bootstrapValidator.min.css'
'bundles/template/components/bootstrap-datepicker/css/datepicker.css'
'bundles/template/components/bootstrap-datepicker/css/datepicker3.css'
'bundles/template/css/tanane.css'
filter='css_url_rewrite'
%}
<link rel="stylesheet" href="{{ asset_url }}" />
{% endstylesheets %}
然后我清空缓存并运行命令assets:install --symlink
,assetic:dump
和assetic:dump --env=prod
和仍然没有看到图像,也FontAwesome字体:
Failed to load resource: the server responded with a status of 404 (Not Found) http://tanane.dev/app_dev.php/css/select2.png
Failed to load resource: the server responded with a status of 404 (Not Found) http://tanane.dev/app_dev.php/css/select2-spinner.gif
Failed to load resource: the server responded with a status of 404 (Not Found) http://tanane.dev/app_dev.php/css/select2.png
Failed to load resource: the server responded with a status of 404 (Not Found) http://tanane.dev/app_dev.php/fonts/fontawesome-webfont.woff?v=4.2.0
Failed to load resource: the server responded with a status of 404 (Not Found) http://tanane.dev/app_dev.php/fonts/fontawesome-webfont.ttf?v=4.2.0
Failed to load resource: the server responded with a status of 404 (Not Found) http://tanane.dev/app_dev.php/fonts/fontawesome-webfont.svg?v=4.2.0#fontawesomeregular
我错过了什么东西?我还能做些什么来解决这个令人讨厌的问题?
固定的禁用方法
我固定的一些错误,我在SpBowerBundle
配置所做的,现在我有这个:
sp_bower:
install_on_warmup: true
allow_root: true
assetic:
enabled: false
nest_dependencies: false
bundles:
TemplateBundle: ~
不过,形象,通过SpBowerBundle
管理仍然没有显示,请参阅附加图像:
我在config.yml
启用assetic
:
assetic:
debug: "%kernel.debug%"
use_controller: false
bundles:
- FrontendBundle
- BackendBundle
- ProductBundle
- CommonBundle
- UserBundle
- TemplateBundle
我应该禁用它,并删除所有这些捆在那里?
另一个测试
继@lenybenard建议我这样做:
{% block stylesheets %}
{% stylesheets filter='css_url_rewrite'
'bundles/template/components/font-awesome/css/font-awesome.min.css'
'bundles/template/components/bootstrap/dist/css/bootstrap.min.css'
'bundles/template/components/bootstrap/dist/css/bootstrap-theme.min.css'
filter='cssrewrite'
%}
<link rel="stylesheet" href="{{ asset_url }}" />
{% endstylesheets %}
{% stylesheets
'bundles/template/components/select2/select2.css'
'bundles/template/css/select2-bootstrap.css'
'bundles/template/components/bootstrapvalidator/dist/css/bootstrapValidator.min.css'
'bundles/template/components/bootstrap-datepicker/css/datepicker.css'
'bundles/template/components/bootstrap-datepicker/css/datepicker3.css'
'bundles/template/css/tanane.css'
filter='cssrewrite'
filter='css_url_rewrite'
%}
<link rel="stylesheet" href="{{ asset_url }}" />
{% endstylesheets %}
{% endblock %}
再重复一次同样的过程:
- 清除缓存
cache:clear & cache:warmup
也rm -rf /var/cache & rm -rf /var/logs
以防万一 - From Symofony2 shell :
assets:install --symlink & assetic:dump & assetic:dump --env=prod
结果:DEV一切都很好,在PROD都是错
如果您不使用默认的'web'路径,请尝试'app/console assets:install path'。 – 2014-09-04 15:20:25
@ Mr.Smith我正在使用默认网络路径 – ReynierPM 2014-09-04 15:26:34
您可以请您发布您的树枝模板的一部分,您定义这些资产并创建链接标签以包含它们 – 2014-09-04 15:32:04