Skip to content

Instantly share code, notes, and snippets.

@enlacee
Created December 13, 2013 17:32
Show Gist options
  • Save enlacee/7947987 to your computer and use it in GitHub Desktop.
Save enlacee/7947987 to your computer and use it in GitHub Desktop.
Configuracion de router, statatic, dinamico y expre-regulares
<?php
// 11111
// $frontController = Zend_Controller_Front::getInstance();
// $router = $frontController->getRouter();
// $route = new Zend_Controller_Router_Route(
// 'copitan',
// array(
// 'module'=>'default',
// 'controller' => 'anb',
// 'action' => 'index'
// )
// );
// $router->addRoute('test', $route);
// 22222
// $frontController = Zend_Controller_Front::getInstance();
// $router = $frontController->getRouter();
// $route = new Zend_Controller_Router_Route(
// 'usuario/:nombre',
// array(
// //'nombre' => 'pepeluchoSeteado',
// 'module'=>'default',
// 'controller' => 'anb',
// 'action' => 'index'
// )
// );
// $router->addRoute('test', $route);
// 3333
// $frontController = Zend_Controller_Front::getInstance();
// $router = $frontController->getRouter();
// $route = new Zend_Controller_Router_Route(
// 'usuario/:nombre',
// array(
// //'nombre' => 'pepeluchoSeteado',
// 'module'=>'default',
// 'controller' => 'anb',
// 'action' => 'index'
// ),
// array('nombre' => '\d+')
// );
// $router->addRoute('test', $route);
// 444 staticas
// $route = new Zend_Controller_Router_Route_Static(
// 'login',
// array('controller' => 'anb', 'action' => 'index')
// );
// $router->addRoute('login', $route);
// 555 EXPRECION REGULAR 01
// $frontController = Zend_Controller_Front::getInstance();
// $router = $frontController->getRouter();
// $values = array(
// //'1' => '2006',
// 'controller' => 'anb',
// 'action' => 'index'
// );
// $route = new Zend_Controller_Router_Route_Regex(
// 'archive/(\d+)',$values);
// $router->addRoute('archive', $route);
// 6666 EXPRECION REGULAR 02 variable dinamico
// $frontController = Zend_Controller_Front::getInstance();
// $router = $frontController->getRouter();
// $route = new Zend_Controller_Router_Route_Regex(
// 'archive(?:/(\d+))?',
// array(
// 1 => '2006',
// 'controller' => 'anb',
// 'action' => 'index'
// )
// );
// $router->addRoute('archive', $route);
$frontController = Zend_Controller_Front::getInstance();
$router = $frontController->getRouter();
$route = new Zend_Controller_Router_Route_Regex(
'archive/(\d+)',
array(
'controller' => 'anb',
'action' => 'index'
),
array(
1 => 'year'
)
);
$router->addRoute('archive', $route);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment