0

使用 Zend Framework Routing (Zend\Mvc\Router\RouteStack),我如何添加一个模块来支持用户配置文件页面。

但我也想让它支持根目录中的其他页面/模块,如/rssor /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',
                    ),
                ),
            ),

网址示例...

4

1 回答 1

0

弄清楚了。在路由树的最末端使用 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',
                        ),
                    ),
于 2012-05-02T20:41:25.383 回答