Viduc
January 17, 2022, 7:11pm
1
Hi, i migrate my project to 4.1 in 4.3. But now when i want use cake bake i have this error message:
`Router::scope()` is deprecated, use the non-static method `RouteBuilder::scope()` instead.
/var/www/TALA/back_end/vendor/cakephp/cakephp/src/Routing/Router.php, line: 929
You can disable all deprecation warnings by setting `Error.errorLevel` to `E_ALL & ~E_USER_DEPRECATED`. Adding `vendor/cakephp/cakephp/src/Routing/Router.php` to `Error.ignoredDeprecationPaths` in your `config/app.php` config will mute deprecations from that file only.
i dont know where is used Router::scope and where i can change it. I dont want modify app.php to ignore deprecated so how can i do?
Thanks for help
The main problem is the fact, that PHP 8.0 removed the context parameter which we used to show the original source of the deprecation.
See context parameter of error handler deprecated · Issue #15195 · cakephp/cakephp · GitHub
If you can’t see the deprecation in the frontend via the debug_kit toolbar then I would only recommend you to grep for that code part like
grep -R 'Router::scope(' .
Viduc
January 18, 2022, 8:09am
3
Hi, thanks for your help.
I search
'Router::scope('
but only found in vendor (vendor/cakephp/cakephp/src/Routing/Router.php), so i cant change it…
To move forward, I therefore modified the error_level while waiting
For information my version of php is 7.4.3
It could also be that some plugin uses the Router::plugin()
method so you can grep for that as well.
Zuluru
January 18, 2022, 8:12pm
5
There’s some way to turn off deprecation notices for plugins, as I recall.
Viduc
January 19, 2022, 7:32am
6
Thanks for your answer,
I add this in my config/app.php:
'Error' => [
'errorLevel' => E_ALL & ~E_USER_DEPRECATED,
and all is ok, i can use cake bake with console.
Otherwise the last resort would be to enable xdebug in your setup and set a breakpoint in that static function which throws the deprecation error.
yousuo
April 16, 2025, 4:22am
8
For those having this issue, you need to check the file at vendor/cakephp/debug_kit/config/routes.php
Compare (or just copy) this from Cakephp4.x github
<?php
use Cake\Routing\Route\DashedRoute;
use Cake\Routing\RouteBuilder;
return function (RouteBuilder $routes) {
$routes->plugin('DebugKit', ['path' => '/debug-kit'], function (RouteBuilder $routes) {
$routes->setExtensions('json');
$routes->setRouteClass(DashedRoute::class);
$routes->connect(
'/toolbar/clear-cache',
['controller' => 'Toolbar', 'action' => 'clearCache']
);
$routes->connect(
'/toolbar/*',
['controller' => 'Requests', 'action' => 'view']
);
$routes->connect(
'/panels/view/latest-history',
This file has been truncated. show original