Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/grails/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Zend框架控制器操作助手_Php_Zend Controller - Fatal编程技术网

Php Zend框架控制器操作助手

Php Zend框架控制器操作助手,php,zend-controller,Php,Zend Controller,添加action helper类后,我遇到了致命错误。我正在尝试加载与调用的布局对应的布局。以下是我的代码片段: 首先,我在application/controller/helpers下添加了一个helper类: class Zend_Controller_Action_Helper_Layout extends Zend_Controller_Action_Helper_Abstract { public $pluginLoader; public function __construc

添加action helper类后,我遇到了致命错误。我正在尝试加载与调用的布局对应的布局。以下是我的代码片段:

首先,我在application/controller/helpers下添加了一个helper类:

class Zend_Controller_Action_Helper_Layout extends Zend_Controller_Action_Helper_Abstract {

public $pluginLoader;


public function __construct() 
{
    // TODO Auto-generated Constructor
    $this->pluginLoader = new Zend_Loader_PluginLoader ();
}


public function preDispatch()
{
        $bootstrap = $this->getActionController()->getInvokeArg('bootstrap');
        $config = $bootstrap->getOptions();
        $module = $this->getRequest()->getModuleName();
        if (isset($config[$module]['resources']['layout']['layout'])) {
            $layoutScript = $config[$module]['resources']['layout']['layout'];
            $this->getActionController()->getHelper('layout')->setLayout($layoutScript);
        }

    }

}
然后我在bootstrap.php中添加了一个加载程序:

protected function _initLayoutHelper() {

    $this->bootstrap('frontController');
    Zend_Controller_Action_HelperBroker::addPath(APPLICATION_PATH .'/controllers/helpers');

    $layout = Zend_Controller_Action_HelperBroker::addHelper(new Zend_Controller_Action_Helper_Layout());
}
[production]
autoloaderNamespaces.tree = "Tree_"
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.frontController.helperDirectory = APPLICATION_PATH "/controllers/helpers"

resources.modules[] = ""
contact.resources.frontController.defaultControllerName = "index"
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts"
resources.layout.layout = layout
admin.resources.layout.layout = admin
#admin.resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts"

resources.view[] =

[staging : production]

[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1

[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
以下是我的应用程序。ini:

protected function _initLayoutHelper() {

    $this->bootstrap('frontController');
    Zend_Controller_Action_HelperBroker::addPath(APPLICATION_PATH .'/controllers/helpers');

    $layout = Zend_Controller_Action_HelperBroker::addHelper(new Zend_Controller_Action_Helper_Layout());
}
[production]
autoloaderNamespaces.tree = "Tree_"
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.frontController.helperDirectory = APPLICATION_PATH "/controllers/helpers"

resources.modules[] = ""
contact.resources.frontController.defaultControllerName = "index"
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts"
resources.layout.layout = layout
admin.resources.layout.layout = admin
#admin.resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts"

resources.view[] =

[staging : production]

[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1

[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
运行此代码时,我遇到以下错误:

protected function _initLayoutHelper() {

    $this->bootstrap('frontController');
    Zend_Controller_Action_HelperBroker::addPath(APPLICATION_PATH .'/controllers/helpers');

    $layout = Zend_Controller_Action_HelperBroker::addHelper(new Zend_Controller_Action_Helper_Layout());
}
[production]
autoloaderNamespaces.tree = "Tree_"
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.frontController.helperDirectory = APPLICATION_PATH "/controllers/helpers"

resources.modules[] = ""
contact.resources.frontController.defaultControllerName = "index"
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts"
resources.layout.layout = layout
admin.resources.layout.layout = admin
#admin.resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts"

resources.view[] =

[staging : production]

[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1

[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
警告: 包括(Zend\Controller\Action\Helper\LayoutLoader.php) [函数.include]:打开失败 流:中没有这样的文件或目录 D:\personal\proj\renove\library\Zend\Loader.php 在线83

警告:include()[function.include]: 打开失败 'Zend\Controller\Action\Helper\LayoutLoader.php' 包括 (包括\u path='D:\personal\proj\renove\application/。/library;D:\personal\proj\renove\library;C:\php5\pear') 在里面 D:\personal\proj\renove\library\Zend\Loader.php 在线83

致命错误:类 “Zend\u控制器\u操作\u助手\u布局加载程序” 在中找不到 D:\personal\proj\renove\application\Bootstrap.php 在线33


请让我知道,我如何才能走出这个问题。我是Zend框架的初学者。

似乎您有无效的
包含路径

set_include_path(implode(PATH_SEPARATOR, array(realpath(APPLICATION_PATH . '/../library'),get_include_path(),)));

/** Zend_Application */
require_once 'Zend/Application.php'; 

// Create application, bootstrap, and run
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
$application->bootstrap()->run();
尝试在index.php中插入以下内容:


define('ROOTDIR', dirname(__FILE__) . DIRECTORY_SEPARATOR);
define('LIBDIR', realpath(ROOTDIR . '../library') . DIRECTORY_SEPARATOR);
set_include_path(implode(PATH_SEPARATOR, array_merge(explode(PATH_SEPARATOR,ini_get('include_path')), array(LIBDIR))));
这适用于目录结构,如:

application/ library/ - Zend/ httpdocs/ - index.php 应用/ 图书馆/ -泽德/ httpdocs/ -index.php
我认为include路径是有效的。下面是我的index.php

定义应用程序目录的路径

defined('APPLICATION_PATH') || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
定义应用程序环境

defined('APPLICATION_ENV') || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'development'));
确保
library/
处于
include\u路径上

set_include_path(implode(PATH_SEPARATOR, array(realpath(APPLICATION_PATH . '/../library'),get_include_path(),)));

/** Zend_Application */
require_once 'Zend/Application.php'; 

// Create application, bootstrap, and run
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
$application->bootstrap()->run();