我正在尝试对 zend 框架进行小测试,以了解它是如何工作的。我创建了一个模块调查。现在,在这个控制器中,我想包含一个在上面一个目录中找到的文件,当我执行这个时,我得到
( ! ) Warning: require(../database.php) [<a href='function.require'>function.require</a>]: failed to open stream: No such file or directory in C:\wamp\www\zend\module\Survey\src\Survey\Controller\SurveyController.php on line 4
Call Stack
# Time Memory Function Location
1 0.0010 367280 {main}( ) ..\index.php:0
2 0.2738 5658600 Zend\Mvc\Application->run( ) ..\index.php:15
3 0.2780 5685104 Zend\EventManager\EventManager->trigger( ) ..\Application.php:297
4 0.2781 5685112 Zend\EventManager\EventManager->triggerListeners( ) ..\EventManager.php:208
5 0.2784 5686672 call_user_func ( ) ..\EventManager.php:464
6 0.2784 5686688 Zend\Mvc\DispatchListener->onDispatch( ) ..\EventManager.php:464
7 0.2785 5686688 Zend\Mvc\Controller\ControllerManager->get( ) ..\DispatchListener.php:90
8 0.2785 5686840 Zend\ServiceManager\AbstractPluginManager->get( ) ..\ControllerManager.php:114
9 0.2786 5686840 Zend\ServiceManager\ServiceManager->get( ) ..\AbstractPluginManager.php:110
10 0.2787 5687256 Zend\ServiceManager\ServiceManager->create( ) ..\ServiceManager.php:437
11 0.2787 5687288 Zend\ServiceManager\AbstractPluginManager->createFromInvokable( ) ..\ServiceManager.php:491
12 0.2788 5687704 Zend\Loader\StandardAutoloader->autoload( ) ..\ServiceManager.php:0
13 0.2788 5687760 Zend\Loader\StandardAutoloader->loadClass( ) ..\StandardAutoloader.php:217
14 0.2850 5694072 include( 'C:\wamp\www\zend\module\Survey\src\Survey\Controller\SurveyController.php' ) ..\StandardAutoloader.php:306
( ! ) Fatal error: require() [<a href='function.require'>function.require</a>]: Failed opening required '../database.php' (include_path='.;C:\php\pear') in C:\wamp\www\zend\module\Survey\src\Survey\Controller\SurveyController.php on line 4
Call Stack
# Time Memory Function Location
1 0.0010 367280 {main}( ) ..\index.php:0
2 0.2738 5658600 Zend\Mvc\Application->run( ) ..\index.php:15
3 0.2780 5685104 Zend\EventManager\EventManager->trigger( ) ..\Application.php:297
4 0.2781 5685112 Zend\EventManager\EventManager->triggerListeners( ) ..\EventManager.php:208
5 0.2784 5686672 call_user_func ( ) ..\EventManager.php:464
6 0.2784 5686688 Zend\Mvc\DispatchListener->onDispatch( ) ..\EventManager.php:464
7 0.2785 5686688 Zend\Mvc\Controller\ControllerManager->get( ) ..\DispatchListener.php:90
8 0.2785 5686840 Zend\ServiceManager\AbstractPluginManager->get( ) ..\ControllerManager.php:114
9 0.2786 5686840 Zend\ServiceManager\ServiceManager->get( ) ..\AbstractPluginManager.php:110
10 0.2787 5687256 Zend\ServiceManager\ServiceManager->create( ) ..\ServiceManager.php:437
11 0.2787 5687288 Zend\ServiceManager\AbstractPluginManager->createFromInvokable( ) ..\ServiceManager.php:491
12 0.2788 5687704 Zend\Loader\StandardAutoloader->autoload( ) ..\ServiceManager.php:0
13 0.2788 5687760 Zend\Loader\StandardAutoloader->loadClass( ) ..\StandardAutoloader.php:217
14 0.2850 5694072 include( 'C:\wamp\www\zend\module\Survey\src\Survey\Controller\SurveyController.php' ) ..\StandardAutoloader.php:306
这是控制器文件
<?php
namespace Survey\Controller;
(require 'test.php');
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
use Zend\Config\Config;
class SurveyController extends AbstractActionController
{
public function indexAction()
{
$plugin = $this->plugin('url');
}
public function addAction()
{
}
public function editAction()
{
}
public function deleteAction()
{
}
}
控制器中的相同代码,当我将 database.php 放在与控制器相同的目录中时,工作正常。为什么它不允许我包含上面的一个目录以及如何解决这个问题?