zoukankan      html  css  js  c++  java
  • phalcon: router规则与解析,已经生成router的链接地址

    本人采用的是假分模块(目录),通过命名空间来进行模块分组的,非官方分组,所以在router是都会加上 namespace 信息,你也可适当的参考:

    前提:

    /**
    	 * 注册命名空间
    	 */
    	$loader->registerNamespaces(array(
    		'controllers' => '../app/controllers'
    	))->register();
    

      

    路由一:

    $router->add("/news/([0-9]{4})/([0-9]{2})/([0-9]{2})/:params",
    			array(
    				"namespace" => 'controllers
    ews',
    				'controller'=>'index',
    				'action'=>'show',
    				'year'=>1,
    				'month'=>2,
    				'day'=>3,
    				'parmas'=>4,
    		));->setName("index-show");
    

    controller:

    <?php
    namespace controllers
    ews;
    use PhalconMvcController;
    class IndexController extends Controller
    {	
    
    	public function indexAction()
    	{
    		
    	}
    
    	public function showAction()
    	{
    		$year = $month = $day = 0;
    		$year = $this->dispatcher->getParam('year');
    		$month = $this->dispatcher->getParam('month');
    		$day = $this->dispatcher->getParam('day');
    		
    		
    
    		$this->view->pick('news/index');
    		$this->view->year = $year;
    		$this->view->month = $month;
    		$this->view->day = $day;
    	}
    }
    

      

    生成链接:

    echo $this->di['url']->get( array(
    			"for" => "index-show",
    			'year'=>"2016",
    				'month'=>"09",
    				'day'=>"20",
    				'parmas'=>"good",
    		));
    

     输出如下: 

    /news/2016/09/20/

      

  • 相关阅读:
    第11组 Alpha冲刺(4/6)
    第11组 Alpha冲刺(3/6)
    第11组 Alpha冲刺(2/6)
    第11组 Alpha冲刺(1/6)
    团队Git现场编程实战
    第11组 团队项目-需求分析报告
    团队项目-选题报告
    第10组 Alpha冲刺(2/6)
    第10组 Alpha冲刺(1/6)
    2019 SDN上机第2次作业
  • 原文地址:https://www.cnblogs.com/achengmu/p/5888231.html
Copyright © 2011-2022 走看看