php – Zend Framework – “指定的控制器无效”

发布时间:2022-04-30 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了php – Zend Framework – “指定的控制器无效”脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
我在实时服务器上设置Zend Framework应用程序时遇到问题.它可以在localhost上正常工作.

我有应用程序的实时服务器地址是:

http://www.domainname.com/new/

一切正常,直到我尝试访问URL http://www.domainname.com/new/admin的管理模块,然后我收到以下错误.

有任何想法吗?

An error occurred
Page not found
Exception information:

Message: Invalid controller sPEcified (index)
Stack trace:

#0 /data/www/www.domainname.com/public_htML/new/library/Zend/Controller/Front.PHP(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http),Object(Zend_Controller_Response_Http))
#1 /data/www/www.domainname.COM/public_html/new/library/Zend/Application/Bootstrap/Bootstrap.PHP(97): Zend_Controller_Front->dispatch()
#2 /data/www/www.domainname.com/public_html/new/library/Zend/Application.PHP(366): Zend_Application_Bootstrap_Bootstrap->run()
#3 /data/www/www.domainname.com/public_html/new/index.PHP(27): Zend_Application->run()
#4 {main}  

Request Parameters:

array (
  'module' => 'admin','controller' => 'index','action' => 'index',)

index.PHP中的包含路径设置正确(库和其他所有内容都已加载),index.PHP文件在这里

// define path to application directory
defined('APPLICATION_PATH')
    || define('APPLICATION_PATH',realpath(dirname(__FILE__) . '/application'));

// Define application environment
defined('APPLICATION_ENV')
    || define('APPLICATION_ENV',(getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'PRoduction'));

set_include_path('library');

// Define upload path
if (!defined('UPLOAD_PATH'))
        define('UPLOAD_PATH',realpath(dirname(__FILE__)) . '/upload/');

/** 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();

Bootstrap.PHP文件

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
    protected function _inITDoctype(){
        $this->bootstrap('view');
        $view = $this->getResource('view');
        $view->doctype('XHTML1_STRICT');
    }

    protected function _initTimeZone(){
        $date = $this->getOption('date');
        date_default_timezone_set($date['timezone']);
    }

    protected function _initLayoutHelper(){
        $this->bootstrap('frontController');
        Zend_Controller_Action_HelperBroker::addHelper(
            new Jakub_Controller_Action_Helper_LayoutLoader());
    }

    protected function _initflashmessenger(){
        $flashMessenger = Zend_Controller_Action_HelperBroker::getstaticHelper('FlashMessenger');

        if ($flashMessenger->hasMessages()) {
            $view = $this->getResource('view');
            $view->;messages = $flashMessenger->getMessages();
        }
    }

    protected function _initAuth(){
        $this->bootstrap('session');
        $auth = Zend_Auth::getInstance();
        if ($auth->hasIdentity()) {
            $view = $this->getResource('view');
            $view->user = $auth->getIdentity();
        }

        return $auth;
    }
}

Application.ini文件

[production]
webhost = "http://www.domainname.com/new"

PHPSettings.display_startup_errors = 1
PHPSettings.display_errors = 1
resources.frontController.params.displayExceptions = 1

includePaths.library = APPLICATION_PATH "/../library"

date.timezone = "Europe/Bratislava"

bootstrap.path = APPLICATION_PATH "/Bootstrap.PHP"
bootstrap.class = "Bootstrap"

appnamespace = "Application"
autoloadernamespaces.nette = "Nette_"
autoloadernamespaces.jakub = "Jakub_"

resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"

resources.view[] =
resources.view.helperPath.App_View_Helper = APPLICATION_PATH "/views/helpers"

resources.modules[] =

resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/default/"
resources.layout.layout = default

admin.resources.layout.layoutPath = APPLICATION_PATH "/modules/admin/layouts/scripts/base/"
admin.resources.layout.layout = default

[staging : production]

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

[development : production]
webhost = "http://domainname"

PHPSettings.display_startup_errors = 1
PHPSettings.display_errors = 1
resources.frontController.params.displayExceptions = 1
在您的管理模块文件夹中,检查IndexController.PHP是否存在于“controllers”子目录中.

如果是,则打开IndexController.PHP并确保类声明确实声明了类“IndexController”(一个常见的复制粘贴陷阱)

编辑:控制器名称应为Admin_IndexController,而不仅仅是IndexController

脚本宝典总结

以上是脚本宝典为你收集整理的php – Zend Framework – “指定的控制器无效”全部内容,希望文章能够帮你解决php – Zend Framework – “指定的控制器无效”所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。