我正在使用Phalcon框架,想学习如何分组路由。官方文件对我帮助不大。
我的路由是这样的:
$app->get('/users', function() {
// do something
});
$app->get('/users/{id}', function($id) {
// do something
});
$app->post('/users', function() {
// do something
});
我想将这些路由分组在"users"组下,这样代码将更清晰和结构化。
我该怎么做?
我使用集合。代码看起来像。
$inbound = new Phalcon'Mvc'Micro'Collection();
$inbound->setHandler('InboundController', true);
$inbound->setPrefix('/v1/inbound');
$inbound->get('/{req_no}', 'readAction');
$inbound->post('/', 'createAction');
$inbound->put('/{req_no}', 'updateAction');
$inbound->delete('/{req_no}', 'deleteAction');