CakePHP 3 路由:前缀范围

CakePHP 3 Routing: Scopes in prefix

我想创建这样的架构:

* Controllers
    * Tracking
        * Instagram
        * Twitter
    * Export
        * Instagram
        * Twitter

例如,我想创建路由 /tracking/instagram/createroutes.php中,我添加了:

Router::prefix('tracking', function (RouteBuilder $routes) {
    \Router::scope('/instagram', function (RouteBuilder $routes) {
        $routes->connect('/create', ['controller' => 'Instagram', 'action' => 'create']);
    });
});

然后我创建了文件 src\Controller\Tracking\InstagramController.php,命名空间 App\Controller\Tracking 和 public 函数 创建()

不幸的是我还有一个:

Error: A route matching "/tracking/instagram/create" could not be found.

在此先感谢您的帮助。

你试试只放这个吗?

Router::prefix('tracking', function (RouteBuilder $routes) {

    $routes->connect('/:controller/:action/*',[], ['routeClass' => 'DashedRoute']);

});