CakePHP中的自定义REST路由

时间:2015-01-17 10:46:05

标签: php rest http cakephp routes

我想使用CakePHP定义自定义REST路由。我可以创建post/user/:id的路线。以下是我routes.php中的相关代码:

Router::connect(
    "/pool/user/:id",
    array(
        '[method]' => 'DELETE',
        'controller' => 'user',
        'action' => 'delete',         
    )
);

现在我想创建一条路由为post/:id/user/:id,其中第一个id是帖子ID,第二个id是用户ID。但是当我这样做时它给了我一个错误:

 preg_match(): Compilation failed: two named subpatterns have the same name at offset 39 [CORE/Cake/Routing/Route/CakeRoute.php, line 195]

如何创建所需的REST路由?

0 个答案:

没有答案