使用Zend Framework Routing(Zend \ Mvc \ Router \ RouteStack),如何添加模块以支持用户配置文件页面。
但是我也希望能够支持来自根目录的其他页面/模块,例如/rss
或/search/asdf
。这是我的第一次猜测,没有运气......
'Zend\Mvc\Router\RouteStack' => array(
'parameters' => array(
'routes' => array(
'default' => array(
'type' => 'Zend\Mvc\Router\Http\Segment',
'options' => array(
'route' => '/[:username[/:action]]',
'constraints' => array(
'username' => '[a-zA-Z][a-zA-Z0-9_-]*',
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
),
'defaults' => array(
'controller' => 'Application\Controller\UserController',
'action' => 'index',
),
),
),
网址示例......
答案 0 :(得分:0)
想出来。在Route树的最末端使用Zend \ Mvc \ Router \ Http \ Regex匹配......
'user' => array(
'type' => 'Zend\Mvc\Router\Http\Regex',
'options' => array(
'regex' => '/(?<id>[a-zA-Z0-9_-]+)',
'defaults' => array(
'controller' => 'Application\Controller\IndexController',
'action' => 'user',
),
'spec' => '/%id%',
),
),
'user-schedule' => array(
'type' => 'Zend\Mvc\Router\Http\Regex',
'options' => array(
'regex' => '/(?<id>[a-zA-Z0-9_-]+)/schedule',
'defaults' => array(
'controller' => 'Application\Controller\IndexController',
'action' => 'schedule',
),
'spec' => '/%id%/schedule',
),
),