Router::redirect() deprecated

212 Views Asked by At

Router::redirect() is deprecated. Use Router::scope() and RouteBuilder::redirect() instead.

The message gives some lead, but did not find direct answer in docs.

Direct switching to RouteBuilder::redirect() instead not possible as it is not static function.

1

There are 1 best solutions below

0
On BEST ANSWER

Ok I found the problem in the end. Easy once you read Router::scope() usage in docs properly and notice you get RouteBuilder object as param for the function.

Docs: https://book.cakephp.org/3/en/development/routing.html#quick-tour


Original (deprecated)

Router::redirect('/old', '/new');  

New

Router::scope('/', function ($routes) {
    $routes->redirect('/old', '/new');
});