问题:我看到空白页
我想要做的就是当我输入
时http://localhost - >转到modules / default / index
http://localhost/admin - >转到modules / admin / index
index.php并不重要。常用设置
文件夹结构
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>
默认控制器
<?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]
错误:
致命错误:第380行的C:\ Program Files(x86)\ Zend \ ZendServer \ share \ ZendFramework \ library \ Zend \ Loader \ Autoloader.php超出了30秒的最长执行时间
答案 0 :(得分:0)
我认为不需要针对此情况的路由器配置?这是Zend Framework的标准行为。
我目前还不确定,但尝试使用“Default _”为您的IndexController添加前缀:
class Default_IndexController extends Zend_Controller_Action
{
}
如果这不起作用,请发布您的重写规则。
答案 1 :(得分: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>