1

问题:我看到空白页

我想做的就是当我打字的时候

http://localhost --> 转到模块/默认/索引

http://localhost/admin --> 进入 modules/admin/index

index.php 已经不重要了。常用设置

文件夹结构

在此处输入图像描述

引导程序.php

<?php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
    protected function _initRoutes()
    {
        $front  = $this->getResource('frontcontroller');
        $router = $front->getRouter();
        $config = new Zend_Config_Xml(APPLICATION_PATH . '/configs/routes.xml');
        $router->addConfig($config->routes);

    }
}

应用程序.ini

[production]

;Debug output
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0

;Include path
includePaths.library = APPLICATION_PATH "/../library"

;Bootstrap
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"

;NameSpace
appnamespace = "Application"

;Front Controller
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.params.displayExceptions = 0

;Modular suport
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.modules[] =

;resources.frontController.params.prefixDefaultModule = "1"
;resources.frontController.defaultModule = "default"

;Views
resources.view.encoding = "UTF-8"
resources.view.basePath = APPLICATION_PATH "/views/"
;resources.view.doctype = "XHTML1_STRICT" 
resources.view.doctype = "XHTML1_TRANSITIONAL"

配置文件

<?xml version="1.0" encoding="UTF-8"?>
<router>
    <routes>
        <some-action>
            <type>Zend_Controller_Router_Route</type>
            <route>:module/:controller</route>
            <defaults>
                <controller>index</controller>
                <action>index</action>
            </defaults>
        </some-action>
    </routes>
</router>

默认控制器

<?php

class IndexController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
    }

    public function indexAction()
    {
        // action body
    }


}

管理员控制器

<?php

class Admin_IndexController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
    }

    public function indexAction()
    {
        // action body
    }


}

.htaccess

SetEnv APPLICATION_ENV development

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

错误:

致命错误:C:\Program Files (x86)\Zend\ZendServer\share\ZendFramework\library\Zend\Loader\Autoloader.php 在第 380 行中超过了 30 秒的最大执行时间

4

2 回答 2

0

I think you doesn't need an Router Configuration for this case? This is the standard behavoir of Zend Framework.

Iam not sure in the moment, but try to Prefix your IndexController with "Default_":

class Default_IndexController extends Zend_Controller_Action
{

}

If this is not working, please post your ReWrite Rule.

于 2011-09-06T06:02:19.863 回答
0

尝试使用以下 xml 为您的路线:

<?xml version="1.0" encoding="UTF-8"?>
<router>
    <routes>
        <front>
            <route>/</route>
            <defaults>
                <module>default</module>
                <controller>index</controller>
                <action>index</action>
            </defaults>
        </front>
        <admin>
            <route>/admin</route>
            <defaults>
                <module>admin</module>
                <controller>index</controller>
                <action>index</action>
            </defaults>
        </admin>
    </routes>
</router>
于 2011-11-24T11:09:55.467 回答