Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/255.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Restful API Zend框架2_Php_Zend Framework2_Restful Url_Zend Rest_Zend Rest Route - Fatal编程技术网

Php Restful API Zend框架2

Php Restful API Zend框架2,php,zend-framework2,restful-url,zend-rest,zend-rest-route,Php,Zend Framework2,Restful Url,Zend Rest,Zend Rest Route,我已经找到了如何通过AbstractRestfulController访问简单资源的方法。例如: localhost/products->列表 localhost/products/1->特殊产品 有办法嵌套资源吗?如果是,你会怎么做?例如: localhost/products/1/photos->列出产品的所有照片 localhost/products/1/photos/3124->显示产品的特殊照片 (我有一个目标) 谢谢你的帮助 您需要添加另一条路线。例如: 'products' =&g

我已经找到了如何通过
AbstractRestfulController
访问简单资源的方法。例如:

localhost/products
->列表
localhost/products/1
->特殊产品

有办法嵌套资源吗?如果是,你会怎么做?例如:

localhost/products/1/photos
->列出产品的所有照片
localhost/products/1/photos/3124
->显示产品的特殊照片

(我有一个目标)


谢谢你的帮助

您需要添加另一条路线。例如:

'products' => array(
                        'type'    => 'Literal',
                        'options' => array(
                            'route'    => '/products',
                            'defaults' => array(
                                'controller' => 'Application\Controller\ProductsRest',
                                'action'     => null
                            )
                        ),
                        'may_terminate' => true,
                        'child_routes'  => array(
                            'photos' => array(
                                'type'    => 'Segment',
                                'options' => array(
                                    'route' => '/:productId/photos'
                                )
                            ),                                
                        )
                    )
'products' => array(
            'type' => 'Segment',
            'options' => array(
                'route' => '/products/:productId[/photos/:photos]',
                'constraints' => array(
                    'productId' => '[0-9]*',
                    'photos' => '[0-9]*'
                ),
                'defaults' => array(
                    'controller' => 'your contrller',
                ),
            ),
        ),