简体   繁体   English

php zend错误:未为此应用程序定义默认模块

[英]php zend error: no default module defined for this application

So I'm using zend framework and I have this code in a file called UrlRouter.php: 因此,我正在使用zend框架,并将此代码保存在一个名为UrlRouter.php的文件中:

class UrlRouter extends Zend_Controller_Plugin_Abstract
{
    public function routeStartup($request)
    {
        $url = $request->getRequestUri();

        echo $url;

    }
}

and then I have this in my index.php 然后我的index.php中有这个

require_once("UrlRouter.php");

$front = Zend_Controller_Front::getInstance();
$front->registerPlugin(new UrlRouter($this->getRequest()));
$front->dispatch();

but then I get the error message: 但是然后我收到错误消息:

Fatal error: Uncaught exception 'Zend_Controller_Exception' with message 'No default module defined for this application' 

what did I do wrong? 我做错了什么?

the controller plugin seems to be doing its job though...it printed the uri properly but then it is followed by that error message 虽然控制器插件似乎正在执行其工作...但它已正确打印了uri,但随后出现该错误消息

如果直接在/ application下有控制器,则需要告诉他们controllers目录是application

$front->setDefaultControllerDirectory('application')

It happens because: 发生的原因是:

  • The request didn't have a module name in it; 该请求中没有模块名称; and
  • There is no default module set. 没有默认模块集。

This means that querying an URL like: 这意味着查询如下URL:

http://path/to/your/app?module=foo

...should work. ...应该管用。 Or you can define a default module: 或者,您可以定义一个默认模块:

$front->setDefaultModule('foo');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM