FreePBX error gui_hidden has a deprecated constructor

freepbxHaving fresh manual installation of FreePBX 14 on CentOS 7 and when access GUI for the first time it throws the following error: Methods with the same name as their class will not be constructors in a future version of PHP; gui_hidden has a deprecated constructor.

In Apache’s error log file I found the following:

Whoops\Exception\ErrorException: Methods with the same name as their class will not be constructors in a future version of PHP; dayNightObject has a deprecated constructor in file /var/www/html/admin/modules/daynight/functions.inc.php on line 9
Stack trace:
1. Whoops\Exception\ErrorException->() /var/www/html/admin/modules/daynight/functions.inc.php:9
2. Whoops\Run->handleError() /var/www/html/admin/bootstrap.php:362
3. require_once() /var/www/html/admin/bootstrap.php:362
4. require_once() /etc/freepbx.conf:9
5. include_once() /var/lib/asterisk/bin/retrieve_conf:19

After inspecting the stack trace more deeply it became clear that this is something related to PHP version and I found that the error occurs on PHP 7 and not on PHP 5. I did not want to downgrade PHP and luckily a workaround was found: we can just turn off FreePBX Error Handling

You may do this by adding $bootstrap_settings['freepbx_error_handler'] before requiring bootstrap.php in /etc/freepbx.conf. You can see an example below:

Please note that if you have a module that is using bootstrap, you can do this before bootstrapping as show below:

The error has gone.

Want me to do this for you? Drop me a line: itgalaxyzzz {at} gmail [dot] com