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',
),
),
),