ROS软路由论坛 ROSABC.com 网络方案网络工程交流

 找回密码
 会员注册

QQ登录

只需一步,快速开始

zend framework的自定义添加路由的代码实例

2014-10-24 14:27| 发布者: admin| 查看: 401| 评论: 0

摘要: 要完成zend framework的自定义的添加路由,下面是成功的代码实例: class Bootstrap extends Zend_Application_Bootstrap_Bootstrap { protected function _initRouter() { $this-bootstrap('frontController'); ...

要完成zend framework的自定义的添加路由,下面是成功的代码实例:
  
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
    protected function _initRouter()
{
    $this->bootstrap('frontController');
    $front = Zend_Controller_Front::getInstance(); // from singleton, for example
    $router = $front->getRouter();
    $route = new Zend_Controller_Router_Route('login',
        array('controller' => 'account', 'action' => 'index'));
    $router->addRoute('login', $route);
    return $router;
}
}

自定义路由是在默认路由的基础上添加新的路由方式,这个很容易理解。我之所以写这个是因为我在过去的两天里面遇到一个很奇葩的问题,按照《Beginning Zend Framework》一书上面的示例在public/index.php下面添加路由,但是怎么都不成功。google搜索了N多次,试了N多次,重装了一次Apache还是不成功,又解决了一个坑爹的问题。

PS:针对常见的Discuz、dedecms、phpwind之类的php cms网站程序,基本上都会用到zend的优化。

不良信息举报Q:2000617

软路由

不良信息举报Q:2000617|Archiver|ROS软路由论坛 ROSABC.com 网络方案网络工程交流

GMT+8, 2025-10-27 20:09 , Processed in 0.030175 second(s), 15 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部