0

I want to implement custom routes in CakePHP. I am following the docs

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

My custom route in 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']);

but I get

Missing Controller

Error: Controller could not be found.

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

When I remove ['routeClass' => 'CategoryRoute'], rerouting just works fine.

Þaw
  • 2,047
  • 4
  • 22
  • 39

1 Answers1

1

Have a closer look at the API documenation: API > CakeRoute::parse()

The parse() method is supposed to return an array of parsed parameters (ie $params) on success, or false on failure.

ndm
  • 59,784
  • 9
  • 71
  • 110