使用此tutorial,我試圖讓Symfony2 CMF啓動並運行。我能夠實現框架,但沒有任何樣式或腳本正在加載。我得到了錯誤的js和css:Symfony CMF CSS未加載:資源解釋爲樣式表,但使用MIME類型text/html傳輸:
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 %}
和
{% block bottom_scripts %}
{% render(controller("cmf_create.jsloader.controller:includeJSFilesAction", { "editor": "ckeditor", "_locale": app.request.locale })) %}
{% endblock %}
從本教程中,這些樣式應該加載正常。我也使用了CMF文檔here,並且可以加載樣式,但遇到許多其他文檔問題。有什麼我需要調整我的config.yml也許?
UPDATE
這似乎與assetic的問題。如果我手動將樣式加載到skeleton.html.twig中,它們就會出現。
資產會導致此MIME類型轉移的任何原因?有些設置我沒有在這個龐大的框架中正確嗎?
這看起來像是你的apache服務器中有一個奇怪的配置,它使得它改變了mime類型,或者是一個看起來不太可能的非常基本的資產問題。 OR:你打開了這些網址嗎?也許有一個symfony文件中的錯誤消息,而不是真正的CSS/JS(因爲資產配置錯誤或缺少東西...) – dbu
我不認爲它是Apache,因爲我已經能夠獲得其他CMF安裝,我在我的本地任何其他symfony2網站上都沒有這個問題。如果我打開網址,則顯示樣式,沒有symfony錯誤。如果我想檢查Apache,我準確地尋找什麼設置? –