如何在 CakePHP 中使用自定义路由?

How to use custom routes in CakePHP?

我想在 CakePHP 中实现自定义路由。我正在关注文档

http://book.cakephp.org/2.0/en/development/routing.html#custom-route-classes

我在 app/Routing/Route

中的自定义路线
<?php

App::uses('CakeRoute', 'lib/Cake/Routing/Route');

class CategoryRoute extends CakeRoute
{
    public function parse($url)
    {
        $params = parent::parse($url);
        if (empty($params)) {
            return false;
        }

        return true;
    }
}

app/Config/routes.php

App::uses('CategoryRoute', 'Routing/Route');
Router::connect('/mypage/*', array('controller' => 'mycontroller', 'action' => 'view'), ['routeClass' => 'CategoryRoute']);

但我得到

Missing Controller

Error: Controller could not be found.

Error: Create the class Controller below in file: app/Controller/Controller.php

当我删除 ['routeClass' => 'CategoryRoute'] 时,重新路由工作正常。

仔细查看 API 文档:API > CakeRoute::parse()

parse() 方法应该在成功时 return 一组已解析的参数(即 $params),或者在失败时 false