我使用Zend 1.8.4並設置了一個簡單的表單測試。我的表單類位於「./application/forms/SectorSearch.php」和類名是Zend表單模塊包含路徑
<?php
class Form_SectorSearch extends Zend_Form
{...}
我的控制器在init()方法
<?php
class SectorController extends Zend_Controller_Action
{
function init()
{
$this->initView();
$form = new Form_SectorSearch(array(
'method' => '/public/sector/search',
'action' => 'post'));
$this->view->form = $form;
}
..
}
但我創建了一個新形式得到這個錯誤
Warning: Zend_Loader_Autoloader_Resource::include(/home/poconnell/projects/bhaa/application/forms/SectorSearch.php) [zend-loader-autoloader-resource.include]: failed to open stream: No such file or directory in /home/poconnell/projects/bhaa/library/Zend/Loader/Autoloader/Resource.php on line 178
Warning: Zend_Loader_Autoloader_Resource::include() [function.include]: Failed opening '/home/poconnell/projects/bhaa/application/forms/SectorSearch.php' for inclusion (include_path='/home/poconnell/projects/bhaa/library:/home/poconnell/projects/bhaa/application:.:/usr/share/php:/usr/share/pear') in /home/poconnell/projects/bhaa/library/Zend/Loader/Autoloader/Resource.php on line 178
Fatal error: Class 'Form_SectorSearch' not found in /home/poconnell/projects/bhaa/application/controllers/SectorController.php on line 19
我100%確定這個類是包含路徑。
我認爲這是一個問題,Bootstrap逼近,這是如何我加載默認模塊
protected function _initAutoload()
{
//Zend_Loader_Autoloader_Resource - Zend_Application_Module_Autoloader
$moduleLoader = new Zend_Application_Module_Autoloader(array(
'namespace' => '',
'basePath' => APPLICATION_PATH
));
return $moduleLoader;
}
我甚至使用這種模式嘗試的建議,Autloading modular forms & models in Zend Framework 1.8
protected function _initAutoload()
{
//Zend_Loader_Autoloader_Resource - Zend_Application_Module_Autoloader
$moduleLoader = new Zend_Application_Module_Autoloader(array(
'namespace' => '',
'basePath' => APPLICATION_PATH,
'resourceTypes' => array (
'form' => array(
'path' => 'forms',
'namespace' => 'Form'))
);
return $moduleLoader;
}
但沒有喜悅。有任何想法嗎?
注意文件名在UperCase中包含它們。從win到linux切換時這是常見的問題。 – powtac 2009-10-15 13:15:24
你是否100%確定該文件具有正確的權限? – PatrikAkerstrand 2009-10-15 13:24:46
poconnell @ foundry:〜/ projects/bhaa/application/forms $ ls -al SectorSearch.php -rw-r - r-- 1 poconnell poconnell 561 2009-10-15 14:41 SectorSearch.php – emeraldjava 2009-10-15 14:03:48