开发者

ZendFramework XML Routing not working

开发者 https://www.devze.com 2023-04-03 09:35 出处:网络
Problem: I see Blank Page All I want to do is when I type http://localhost --> Go to modules/default/index

Problem: I see Blank Page

All I want to do is when I type

http://localhost --> Go to modules/default/index

http://localhost/admin --> Go to modules/admin/index

index.php has not important. Common settings

Folder Structure

ZendFramework XML Routing not working

Bootstrap.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);

    }
}

application.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"

Config.xml

<?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>

default controller

<?php

class IndexController extends Zend_Controller_Action
{

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

    public function indexAction()
    {
        // action body
    }


}

admi开发者_StackOverflow社区n controller

<?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]

ERROR:

Fatal error: Maximum execution time of 30 seconds exceeded in C:\Program Files (x86)\Zend\ZendServer\share\ZendFramework\library\Zend\Loader\Autoloader.php on line 380


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.


try it with the following xml for your routes:

<?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>
0

精彩评论

暂无评论...
验证码 换一张
取 消