Yii 什么是;“强制编译”;当你使用更少的时候,你的意思是什么?
我有这个:Yii 什么是;“强制编译”;当你使用更少的时候,你的意思是什么?,yii,Yii,我有这个: 'components'=>array( 'less'=>array( 'class'=>'ext.less.components.LessCompiler', 'forceCompile'=> true, //YII_DEBUG, // indicates whether to force compiling //'compress'=>false, // indicates whether to compress comp
'components'=>array(
'less'=>array(
'class'=>'ext.less.components.LessCompiler',
'forceCompile'=> true, //YII_DEBUG, // indicates whether to force compiling
//'compress'=>false, // indicates whether to compress compiled CSS
//'debug'=>false, // indicates whether to enable compiler debugging mode
'paths'=>array(
'less/style.less'=>'css/style.css',
),
),
如果我启用forceCompile,我的站点速度会非常慢。我可以想象,因为它会在每次加载页面时重新生成css。我的问题是禁用它。如果我禁用它:
(是的,我找了所有的人都想得到一个清楚的解释……我能找到的最好的解释是)。首先,让我告诉你:
现在是分机: 即使禁用了
forceCompile
,在style.less中所做的更改也会反映出来,因为扩展名会检查文件是否被修改(LessCompiler.php中的以下几行应该会让您确信这一点):
因此,
forceCompile
将始终编译您在路径中指定的文件,您不应在生产中启用它。hasChanges
调用应该处理较少的已修改文件,并编译它们,正如您在上面看到的那样,这是由扩展名自动完成的。较少的点,如较少的语言或较少的扩展名?两者兼而有之。扩展实现的更少?你为什么这么问?(我想我没抓住你问题的重点……)少了朗,肯定也在生产中使用。分机是你的选择
if ($this->forceCompile || $this->hasChanges())
$this->compileAll();
// ...
/**
* Returns whether any of files configured to be compiled has changed.
* @return boolean the result.
*/
protected function hasChanges() {
// ...
$compiled = $this->getLastModified($destination);
// ...
$modified = $this->getLastModified($dir);
// ...
}
/**
* Returns the last modified for a specific path.
* @param string $path the path.
* @return integer the last modified (as a timestamp).
*/
protected function getLastModified($path){
//...
}