我只想知道我們是否可以添加一個配置文件來擴展模塊中的main.conf。模塊可以有自己的配置文件嗎?
5
A
回答
2
它已經。在CWebModule中通過$ this-> setComponents如下:
<?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.*',
));
}
} ?>
1
這樣做的方法是在main的params項中爲模塊/ etc創建一個數組項配置數組。
看這個論壇的帖子:http://www.yiiframework.com/forum/index.php/topic/24617-custom-configuration/
如果你希望你的配置是在一個單獨的文件,你可以在配置文件中的主配置陣列合併了! 這樣的事情應該工作:
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
);
如果你把你的自定義配置數組作爲第二個參數也將覆蓋從主配置屬性。
1
我從來沒有做過,但:
- 電流解決方案在a wiki article提供。
- 關於這個'功能要求',這已經在Yii的論壇上提出過了,這並不是什麼大驚喜。見here和here。
相關問題
- 1. flash.display.Bitmap可以自己設置事件嗎?
- 2. Obj-C塊可以執行自己嗎?
- 3. DLL應該有自己的配置文件嗎?
- 4. Upstart作業配置文件有自己的變量嗎?
- 5. PowerShell模塊可以卸載自己
- 6. 你可以創建自己的任務配置嗎?
- 7. VHDL配置可以使用它自己的泛型嗎?
- 8. Codeigniter以用戶編輯只有自己的配置文件
- 9. 我可以訪問模板中的AngularJS模塊配置值嗎?
- 10. 模塊可以下載文件嗎?
- 11. 可以安裝自己的插件嗎?
- 12. 我可以自定義CakePHP配置文件夾位置嗎?
- 13. CMake可以生成配置文件嗎?
- 14. .NET自己的配置文件
- 15. 多模塊maven原型可以設置爲可選模塊嗎?
- 16. 我的iPhone可以配置兩個配置文件嗎?
- 17. WiFi模塊可以檢測位置嗎?
- 18. Autofac模塊應該註冊自己的從屬模塊嗎?
- 19. 可以自定義Azure AD B2C配置文件內容嗎?
- 20. 我可以配置pydev自動編譯cython文件嗎?
- 21. 可以在反應組件中擁有自己的屬性嗎?
- 22. 可以配置:: IniFiles讀取有錯誤的文件嗎?
- 23. Apache模塊可以在運行時注入配置嗎?
- 24. 我可以在android上實現自己的文件系統嗎?
- 25. 我可以創建我自己的php.ini文件嗎?
- 26. Windows DLL可以檢索自己的文件名嗎?
- 27. 可以將log4net配置爲以其自己的身份運行?
- 28. playframework 2模塊有可能擁有自己的路由文件和控制器嗎?
- 29. 如何在自己的配置文件中配置SysCache?
- 30. 模塊可以有屬性嗎?