以下是我的文件配置,使每件东西都具有功能(但它不是)。我做了一个缓存清除,一个php app/console assests:intall web,没有什么新的。总是收到以下错误消息:Cannot load resource "."。
app/config.php
twig:
paths:
"%kernel.root_dir%/../src/Acme/TestBundle": AcmeTestBundle
assetic:
debug: "%kernel.debug%"
use_controller: false
bundles: [AcmeTestBundle]app/config_dev.php
assetic:
use_controller: falseapp/routing_dev.php
_assetic:
resource: .
type: asseticsrc/Acme/TestBundle/Resources/views/Default/index.html.twig
{% javascripts '@AcmeTestBundle/Resources/public/js/main.js' %}
<script src="{{ asset_url }}"></script>
{% endjavascripts %}src/Acme/TestBundle/Resources/public/js/main.js
console.log('hello');
有没有人知道我是否在配置文件或树枝文件中遗漏了什么东西,从而最终找到了路由:P?谢谢你们。
发布于 2015-11-14 23:37:57
尝试像这样配置:
1-将您的资源放在“公共”文件夹中,可在以下文件中找到:
YourBundle/Resources/config/public/css
YourBundle/Resources/config/public/js
YourBundle/Resources/config/public/images
YourBundle/Resources/config/public/fonts2-在某些项目中,我将Yuicompressor用于Assetic (Yuicompreser2.4.7在windows平台上工作得很好),并将yuicompressor 2.4.7.jar放入:
app/Resources/java/yuicompressor-2.4.7.jar重要: java需要运行时环境1.7,因为它安装在C:\Program (X86)\Java 7\bin (Win64Bits)中。
3-设置config.yml
...
assetic:
debug: "%kernel.debug%"
use_controller: false
bundles: [ ]
java: "C:/Program Files (x86)/Java/jre7/bin/java.exe"
filters:
cssrewrite: ~
#closure:
# jar: "%kernel.root_dir%/Resources/java/compiler.jar"
yui_css:
jar: "%kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar"
yui_js:
jar: "%kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar"
...4-在templete树枝中使用样式表和javascripts块
对于css文件,可以使用:
{% stylesheets
'bundles/app/css/styles.css'
'bundles/app/css/others.css'
filter='?yui_css, cssrewrite'
output='css/common-stylesheets.css' %}
<link href="{{ asset_url }}" rel="stylesheet" />
{% endstylesheets %}对于your脚本文件,可以使用:
{% javascripts
'@AppBundle/Resources/public/js/myApp.js'
'@AppBundle/Resources/public/js/otherFiles.js'
filter='?yui_js'
output='js/common-javascripts.js' %}
<script src="{{ asset_url }}" type="text/javascript"></script>
{% endjavascripts %}5-运行命令Symfony
app/console cache:clear
app/console cache:clear --env=prod
app/console assets:install web
app/console assetic:dump
app/console assetic:dump --env=prod6-检查创建的文件
如果您转到symfony项目中的web文件夹,您可以看到下一个文件:
web/css/common-stylesheets.css
web/javascript/common-javascripts.jshttps://stackoverflow.com/questions/33702382
复制相似问题