老问题,请参阅下面的更新版本
我的开发环境不是最快的。每个 PHP 请求大约需要 500 毫秒。它开始成为 Symfony2 资源文件的问题,因为每个资源文件都是通过 Symfony 的内部控制器请求的:
http://localhost/myproj/app_dev.php/js/bb8690a_part_4_myJavaScriptFile_2.js
可以看出,文件是通过 Symfony 框架加载的,而不是直接加载的。由于我开始要加载 20 多个文件,因此将其乘以 500 毫秒会使页面加载速度非常慢。我想直接加载文件,但我不知道该怎么做。
这是config.yml
:
# Assetic Configuration
assetic:
debug: %kernel.debug%
use_controller: false
# java: /usr/bin/java
filters:
cssrewrite: ~
我以为设置use_controller
to false
会这么做,但是不行。
有没有办法直接处理这些资源的加载?
UPDATE:
这是它现在尝试使用的 URL:
http://localhost/myproj/_controller/js/bb8690a_part_4_myJavaScriptFile_2.js
我已经设定use_controller
to false
对于开发和通用配置。我该如何摆脱它_controller
网址的一部分?
编辑:如果我清除缓存,请运行assetic:dump
并有use_controller
as false
,然后重新加载后我得到Cannot load resource "."
。除非我暂时启用,否则我无法解决这个问题use_controller
对于一页加载。之后,我禁用它并重新加载,现在它从包含的无效 URL 请求_controller
.
它似乎也适用于生产环境,但不适用于开发环境。奇怪的。
模板代码:
{% stylesheets filter="cssrewrite"
'bundles/outotecofil/css/reset.css'
'bundles/outotecofil/css/*'
output='css/dist/dist.css'
%}
<link rel="stylesheet" href="{{ asset_url }}" />
{% endstylesheets %}
{% javascripts
'@OutotecCommonBundle/Resources/public/js/jquery-1.6.2.min.js'
'@OutotecCommonBundle/Resources/public/js/jquery-ui-1.8.16.custom.min.js'
'@OutotecCommonBundle/Resources/public/js/chosen.jquery.min.js'
'@OutotecCommonBundle/Resources/public/js/widget/*'
'@OutotecOFILBundle/Resources/public/js/OFILDependencyManager.js'
'@OutotecOFILBundle/Resources/public/js/widget/*'
'@OutotecOFILBundle/Resources/public/js/plant-scope.js'
output='js/dist/dist.js'
%}
<script src="{{ asset_url }}"></script>
{% endjavascripts %}
非常清楚的是:如果没有 app_dev.php (即在生产模式下),它works。仅在开发中,它不会并抛出此“无法加载资源”。“”错误,除非我首先启用use_controller
对于一个请求,之后我可以禁用它并重新加载,尽管 URL 将包含_controller/
在他们的道路上。