【发布时间】:2009-10-15 13:10:25
【问题描述】:
我正在使用 Zend 1.8.4 并设置一个简单的表单测试。我的表单类位于'./application/forms/SectorSearch.php',类名是
<?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% 确定该类位于包含路径中。
我认为这是一个引导问题,这就是我加载默认模块的方式
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;
}
但没有快乐。有什么想法吗?
【问题讨论】:
-
在包含文件名时请注意文件名是否为大写。这是从win切换到linux时的常见问题。
-
您是否 100% 确定该文件具有正确的权限?
-
poconnell@foundry:~/projects/bhaa/application/forms$ ls -al SectorSearch.php -rw-r--r-- 1 poconnell poconnell 561 2009-10-15 14:41 SectorSearch .php
-
APPLICATION_PATH 的值是多少?
标签: php zend-framework