Warning Message after Installation Version 4.4.12

Hello,

I am new to CakePHP. And got a warning message after start my localhost index page.

Version: CakePHP 4.4.12 Strawberry

Deprecated : Use of BaseErrorHandler and subclasses are deprecated. Upgrade to the new ErrorTrap and ExceptionTrap subsystem. See 4.4 Migration Guide - 4.x /Users/nanohe/Sites/localhost/cms/config/bootstrap.php, line: 129 You can disable all deprecation warnings by setting Error.errorLevel to E_ALL & ~E_USER_DEPRECATED. Adding config/bootstrap.php to Error.ignoredDeprecationPaths in your config/app.php config will mute deprecations from that file only. in /Users/nanohe/Sites/localhost/cms/vendor/cakephp/cakephp/src/Core/functions.php on line 323

And I tried to fix it via the message above.

I tried as below,

nanohe@Nanos-MacBook-Pro cms % php composer.phar require --update-with-dependencies “cakephp/cakephp:^4.4”
./composer.json has been updated
Running composer update cakephp/cakephp --with-dependencies
Loading composer repositories with package information
Updating dependencies
Nothing to modify in lock file
Installing dependencies from lock file (including require-dev)
Nothing to install, update or remove
Generating autoload files
57 packages you are using are looking for funding.
Use the composer fund command to find out more!
No security vulnerability advisories found
nanohe@Nanos-MacBook-Pro cms % bin/cake server

Seems there is not anything need be upgrade.

And I also opened the two files below, but I can’t find anything related to the warning message at the beginning.

/Users/nanohe/Sites/localhost/cms/config/bootstrap.php
/Users/nanohe/Sites/localhost/cms/vendor/cakephp/cakephp/src/Core/functions.php

and my screen capture as this,

Coud anyone give me any advice, appreciated for your help, thanks.

Regards,

Nano HE

You did update the CakePHP Core to 4.4.12 but didn’t update the app template which was created whenever you executed composer create projeckt cakephp/app

See the “Update” section of GitHub - cakephp/app: CakePHP application template

In your specific case you need to update your config/bootstrap.php to what is present in

Which is also described here 4.4 Migration Guide - 4.x

1 Like

by following the guide URL: https://book.cakephp.org/4/en/development/errors.html

And modified the code in file of /Users/nanohe/Sites/localhost/cms/config/app.php
as this,

'ignoredDeprecationPaths' => [
            'config/bootstrap.php',  // inserted the line here to fix my warning issue
        ],

Now there is no any warning message now. I am not sure it is a correct method or not. while the warning message gone.

you are now just ignoring the deprecations which is not the recommended solution.

Instead you should replace the deprecated code parts with the new ones.

Basically all you need to do is copy paste the bootstrap.php file from my link above to your app and you should be fine.

1 Like

Hi Kevin, your suggestion works quite well. Thanks a lot.