0

我正在使用 Phalcon 框架并想学习如何对路由进行分组。官方文档对我帮助不大。

这就是我的路线的样子:

$app->get('/users', function() {
   // do something
});

$app->get('/users/{id}', function($id) {
   // do something
});

$app->post('/users', function() {
   // do something
});

我想将这些路由分组在“用户”组下,以便代码更加清晰和结构化。

我该怎么做?

4

1 回答 1

0

我对此使用收藏。代码看起来像。

$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');
于 2015-06-04T02:28:43.343 回答