PHP Slim获取当前路由组

时间:2015-08-23 12:55:16

标签: php rest routes slim

我想获得当前的路线组 例如来自

group1
$app->group('/group1', function () use ($app) {
    $app->get("/a"...
    $app->get("/b"...
    $app->get("/c"...
...

我可以从当前路线获得路线模式
问题是 - 是否有任何特殊方式来获取当前路线组?

1 个答案:

答案 0 :(得分:0)

$this怎么样?代码取from their website.

$app = new \Slim\App();
$app->group('/users/{id:[0-9]+}', function () {
    $this->map(['GET', 'DELETE', 'PATCH', 'PUT'], '', function ($request, $response, $args) {
        // Find, delete, patch or replace user identified by $args['id']
    })->setName('user');
    $this->get('/reset-password', function ($request, $response, $args) {
        // Reset the password for user identified by $args['id']
    })->setName('user-password-reset');
});