PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, March 13, 2022

[FIXED] Router::redirect() deprecated

 March 13, 2022     cakephp, cakephp-3.8     No comments   

Issue

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.


Solution

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');
});  


Answered By - Nedvajz
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing