1
試圖導入(返回的Yii配置之前),而在config/main.php
一類:Yii框架:導入類而在config/main.php文件
//class LanguageSettings is placed directly in protected/components/LanguageSettings.php
Yii::import('application.components.*');
LanguageSettings::currentLanguage();
導致該致命錯誤:
Fatal error: Uncaught exception 'CException' with message
'Alias "application.components.*" is invalid. Make sure it points to an existing
directory or file.' in C:\xampp\htdocs\yii\framework\YiiBase.php:
爲什麼?在導入配置數組之前,Yi Yii能否正確解析別名?
謝謝你的回答。有沒有其他路徑可以導入(手動)? – Sebastian
好吧,因爲通常basePath(在config/main.php中)定義爲dirname(__ FILE __)。DIRECTORY_SEPARATOR。'..'你可以在main.php頂部的變量($ myBasePath)中定義它,然後手動執行import_once($ myBasePath。'/components/myComponent.php')繞過Yii的自動導入功能。有點哈克,雖然... – stratosgear
哈克,但有幫助。謝謝 ! ps。 import_once = include/require_once。 – Sebastian