【问题标题】:More zend framework2 routing issues更多zend framework2路由问题
【发布时间】:2014-12-22 17:14:15
【问题描述】:

我设法弄清楚了 zf2 中路由的基础知识。我现在遇到了一个绊脚石,因为我需要在我的客户控制器中路由到不同的方法。这是我基于社区答案的尝试:

 // Customers Routing
            'customers' => array(
            'type'    => 'Segment',
                'options' => array(

                    'route'   => '/api/customers[/]',
                    'defaults' => array(
                        '__NAMESPACE__' => 'Application\Controller',
                        'controller'    => 'Customers',
                        'action'        => 'index'
                    ),
                ),

                'may_terminate' => true,
                'child_routes' => array (
                    'add-product' => array(
                        'type' => 'method',
                        'options' => array(
                            'verb' => 'get',
                        ),
                        'child_routes' => array(
                            // actual route is a child of the method
                            'form' => array(
                                'may_terminate' => true,
                                'type' => 'Segment',
                                'options' => array(
                                    'route' => '/api/customers/[:id][/]',
                                    'defaults' => array(
                                    'controller' => 'Customers',
                                    'action' => 'all',
                                    ),
                                ),
                            ),
                        ),
                    ),
                ),
            ),

【问题讨论】:

    标签: routing zend-framework2


    【解决方案1】:

    你的问题在哪里?

    在此示例中,您的表单 child_route 可通过 url /api/customers/api/customers/[:id] 获得,因为 parents-route 是预先设置的。

    【讨论】:

    • 啊,这就是我需要知道的,我不确定我是否将子路线放在正确的位置,因为我认为它更像是一个最佳匹配系统。谢谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多