我試圖運行與誼在命令行上的命令。我的方法需要一個模型,但是當我運行命令,Yii中說,模型不存在,因爲如果它不自動加載它。我的階級是相當簡短:Yii的命令行不自動加載模型
class ImportCommand extends CConsoleCommand {
public function actionIndex() {
}
public function actionImport() {
ini_set("display_errors", 1);
set_time_limit(0);
$cores = Core::model() -> findAll(array('limit' => 300000));
foreach($cores as $core) {
$core -> syncLocation();
}
}
}
錯誤信息是這樣的:
./yiic import import
PHP Warning: PHP Startup: Unable to load dynamic library '/opt/local/lib/php/extensions/no-debug-non-zts-20090626/php_xsl.dll' - dlopen(/opt/local/lib/php/extensions/no-debug-non-zts-20090626/php_xsl.dll, 9): image not found in Unknown on line 0
PHP Error[2]: include(Core.php): failed to open stream: No such file or directory
in file /Users/dixond/Sites/nevada/yii/framework/YiiBase.php at line 421
#0 /Users/dixond/Sites/nevada/yii/framework/YiiBase.php(421): autoload()
#1 unknown(0): autoload()
#2 /Users/dixond/Sites/nevada/pub/webservice/protected/commands/ImportCommand.php(15): spl_autoload_call()
#3 unknown(0): ImportCommand->actionImport()
#4 /Users/dixond/Sites/nevada/yii/framework/console/CConsoleCommand.php(172): ReflectionMethod->invokeArgs()
#5 /Users/dixond/Sites/nevada/yii/framework/console/CConsoleCommandRunner.php(67): ImportCommand->run()
#6 /Users/dixond/Sites/nevada/yii/framework/console/CConsoleApplication.php(91): CConsoleCommandRunner->run()
#7 /Users/dixond/Sites/nevada/yii/framework/base/CApplication.php(169): CConsoleApplication->processRequest()
#8 /Users/dixond/Sites/nevada/yii/framework/yiic.php(33): CConsoleApplication->run()
#9 /Users/dixond/Sites/nevada/pub/webservice/protected/yiic.php(7): require_once()
#10 /Users/dixond/Sites/nevada/pub/webservice/protected/yiic(4): require_once()
是不是有什麼特別的我必須做的就是Yii的自動加載模式?
我覺得你的道路是錯誤的,請檢查您urlrewrite規則 – Gunnit 2013-03-25 13:18:57