2015-08-23 57 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'); 
});