2015-08-23 61 views
0

我想获取当前路线组。
例如group1
PHP Slim获取当前路线组

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

我可以从当前的路线路由模式
问题是 - 有没有什么特别的方法可以获得当前的路由组?

回答

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'); 
});