我使用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