Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/255.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Symfony CMF CSS未加载:资源被解释为样式表,但使用MIME类型text/html传输:_Javascript_Php_Css_Symfony_Symfony Cmf - Fatal编程技术网

Javascript Symfony CMF CSS未加载:资源被解释为样式表,但使用MIME类型text/html传输:

Javascript Symfony CMF CSS未加载:资源被解释为样式表,但使用MIME类型text/html传输:,javascript,php,css,symfony,symfony-cmf,Javascript,Php,Css,Symfony,Symfony Cmf,使用这个,我试图让Symfony2 CMF启动并运行。我能够启动框架,但没有加载任何样式或脚本。我得到了js和css的错误: Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://cmf.local/app_dev.php/css/3428277_bootstrap.min_1.css". en:14 Resource interpreted as Stylesheet but t

使用这个,我试图让Symfony2 CMF启动并运行。我能够启动框架,但没有加载任何样式或脚本。我得到了js和css的错误:

Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://cmf.local/app_dev.php/css/3428277_bootstrap.min_1.css". en:14
Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://cmf.local/app_dev.php/css/06935bc_font-awesome_3.css". en:32
Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://cmf.local/app_dev.php/css/3428277_style_3.css". en:28
Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://cmf.local/app_dev.php/css/06935bc_create-ui_2.css". en:31
Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://cmf.local/app_dev.php/css/06935bc_tags_1.css". en:30
Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://cmf.local/app_dev.php/css/3428277_bootstrap-responsive.min_2.css". en:21
Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://cmf.local/app_dev.php/css/06935bc_overlay_7.css". en:36
Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://cmf.local/app_dev.php/css/06935bc_createStyle_6.css". en:35
Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://cmf.local/app_dev.php/css/06935bc_midgardnotif_4.css". en:33
Resource interpreted as Script but transferred with MIME type text/html: "http://cmf.local/app_dev.php/js/create_jquery_1.js". en:283
Resource interpreted as Script but transferred with MIME type text/html: "http://cmf.local/app_dev.php/js/create_jquery-ui_2.js". en:284
Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://cmf.local/app_dev.php/css/06935bc_halloCmfStyle_5.css". en:34
Resource interpreted as Script but transferred with MIME type text/html: "http://cmf.local/app_dev.php/js/create_underscore_3.js". en:285
Resource interpreted as Script but transferred with MIME type text/html: "http://cmf.local/app_dev.php/js/create_rangy-core_5.js". en:287
Resource interpreted as Script but transferred with MIME type text/html: "http://cmf.local/app_dev.php/js/create_vie_6.js". en:288
Resource interpreted as Script but transferred with MIME type text/html: "http://cmf.local/app_dev.php/js/create_backbone_4.js". en:286
Resource interpreted as Script but transferred with MIME type text/html: "http://cmf.local/app_dev.php/js/create_jquery.rdfquery.core_7.js". en:289
Resource interpreted as Script but transferred with MIME type text/html: "http://cmf.local/app_dev.php/js/create_jquery.rdfquery.rules_8.js". en:290
Resource interpreted as Script but transferred with MIME type text/html: "http://cmf.local/app_dev.php/js/create_annotate_10.js". en:292
Resource interpreted as Script but transferred with MIME type text/html: "http://cmf.local/app_dev.php/js/create_create_11.js". en:293
Resource interpreted as Script but transferred with MIME type text/html: "http://cmf.local/app_dev.php/js/create_jquery.tagsinput_9.js". en:291
Resource interpreted as Script but transferred with MIME type text/html: "http://cmf.local/app_dev.php/js/ckeditor_ckeditor_1.js". en:297
Resource interpreted as Script but transferred with MIME type text/html: "http://cmf.local/app_dev.php/js/ckeditor_init-create-ckeditor_2.js". en:298
Resource interpreted as Script but transferred with MIME type text/html: "http://cmf.local/app_dev.php/js/ckeditor_init-create-common_3.js". 
这些样式和脚本是从skeleton.html.twig:

{% stylesheets
    ...             
    <link rel="stylesheet" href="{{ asset_url }}" media="screen" type="text/css"/>
 {% endstylesheets %}
从教程中,这些样式应该可以很好地加载。我还使用了CMF文档,可以加载样式,但是文档中遇到了很多其他问题。我的config.yml中是否有需要调整的内容

更新

这似乎是assetic的一个问题。如果我手动将样式加载到skeleton.html.twig中,它们就会出现

为什么assetic会导致此mime类型传输?在这个庞大的框架中,我的某些设置不正确?

尝试转储assetic:

$  app/console assetic:dump


09:27:19 [file+] /var/www/app/../web/css/06935bc.css
09:27:19 [file+] /var/www/app/../web/css/06935bc_tags_1.css
09:27:19 [file+] /var/www/app/../web/css/06935bc_create-ui_2.css
09:27:19 [file+] /var/www/app/../web/css/06935bc_font-awesome_3.css
09:27:19 [file+] /var/www/app/../web/css/06935bc_midgardnotif_4.css
09:27:19 [file+] /var/www/app/../web/css/06935bc_halloCmfStyle_5.css
09:27:19 [file+] /var/www/app/../web/css/06935bc_createStyle_6.css
09:27:19 [file+] /var/www/app/../web/css/06935bc_overlay_7.css
09:27:19 [file+] /var/www/app/../web/js/ckeditor.js
09:27:19 [file+] /var/www/app/../web/js/ckeditor_ckeditor_1.js
09:27:19 [file+] /var/www/app/../web/js/ckeditor_init-create-ckeditor_2.js
09:27:19 [file+] /var/www/app/../web/js/ckeditor_init-create-common_3.js
09:27:19 [file+] /var/www/app/../web/js/create.js
09:27:19 [file+] /var/www/app/../web/js/create_jquery_1.js
09:27:19 [file+] /var/www/app/../web/js/create_jquery-ui_2.js
09:27:19 [file+] /var/www/app/../web/js/create_underscore_3.js
09:27:19 [file+] /var/www/app/../web/js/create_backbone_4.js
09:27:19 [file+] /var/www/app/../web/js/create_rangy-core_5.js
09:27:19 [file+] /var/www/app/../web/js/create_vie_6.js
09:27:19 [file+] /var/www/app/../web/js/create_jquery.rdfquery.core_7.js
09:27:19 [file+] /var/www/app/../web/js/create_jquery.rdfquery.rules_8.js
09:27:19 [file+] /var/www/app/../web/js/create_jquery.tagsinput_9.js
09:27:19 [file+] /var/www/app/../web/js/create_annotate_10.js
09:27:19 [file+] /var/www/app/../web/js/create_create_11.js
09:27:19 [file+] /var/www/app/../web/js/hallo-extra.js
09:27:19 [file+] /var/www/app/../web/js/hallo-extra_jquery.htmlClean_1.js
09:27:19 [file+] /var/www/app/../web/js/hallo-extra_hallo_2.js
09:27:19 [file+] /var/www/app/../web/js/hallo-extra_init-create-hallo_3.js
09:27:19 [file+] /var/www/app/../web/js/hallo-extra_init-create-common_4.js

这是一个解决方法,因为文档中没有建议这种方法,但在我遇到同样的问题后,我解决了这个问题的方法是在输出属性中设置css文件的扩展名。默认情况下,它们最终被链接而没有扩展名

{% stylesheets '@asset_test_css' output="css/test.css" %}

这看起来要么是apache服务器中有一个奇怪的配置使其更改了mime类型,要么是一个看起来不太可能的非常基本的资产问题。或者:你打开过这些网址吗?也许文件中有一条symfony错误消息,而不是真正的css/js(因为assetic配置错误或丢失了一些东西…),我认为这不是apache,因为我已经能够安装其他CMF,并且我在本地的任何其他symfony2站点上都没有这个问题。如果我打开URL,样式就会显示出来,没有symfony错误。如果我想检查apache,我到底要找什么设置?
{% stylesheets '@asset_test_css' output="css/test.css" %}