Yii 模块是否可以有自己的配置文件?
我只是想知道我们是否可以在模块中添加一个扩展main.conf的配置文件,方法是在主配置数组的params项中为模块/etc创建一个数组项 请看此论坛帖子: 如果您想将配置放在一个单独的文件中,可以将其与配置文件中的主配置数组合并! 像这样的方法应该会奏效:Yii 模块是否可以有自己的配置文件?,yii,Yii,我只是想知道我们是否可以在模块中添加一个扩展main.conf的配置文件,方法是在主配置数组的params项中为模块/etc创建一个数组项 请看此论坛帖子: 如果您想将配置放在一个单独的文件中,可以将其与配置文件中的主配置数组合并! 像这样的方法应该会奏效: include("custom_config.php"); // define $array_from_custom_conf inside this file return array_merge( array(/*main_con
include("custom_config.php"); // define $array_from_custom_conf inside this file
return array_merge(
array(/*main_config_array from main.php*/),
$array_from_custom_conf
);
如果将自定义配置数组作为第二个参数,它还将覆盖主配置中的属性。我从未这样做过,但:
- 中提供了当前的解决方案
- 关于这个“功能请求”,Yii的论坛上已经请求了它,这并不奇怪。见和
<?php
class AccountModule extends CWebModule
{
public function init()
{
// this method is called when the module is being created
// you may place code here to customize the module or the application
$this->setComponents(array(
'errorHandler' => array(
'errorAction' => 'module/default/error'),
'defaultController' => 'default',
'user' => array(
'class' => 'ModuleWebUser',
'allowAutoLogin'=>true,
'loginUrl' => Yii::app()->createUrl('module/default/login'),
)
));
// import the module-level models and components or any other components..
$this->setImport(array(
'module.models.*',
'module.components.*',
));
}
} ?>