Having 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:
1 2 3 4 5 6 7 8 9 10 11 |
$amp_conf['AMPDBUSER'] = 'freepbxuser'; $amp_conf['AMPDBPASS'] = 'changeme'; $amp_conf['AMPDBHOST'] = 'localhost'; $amp_conf['AMPDBNAME'] = 'asterisk'; $amp_conf['AMPDBENGINE'] = 'mysql'; $amp_conf['datasource'] = ''; //for sqlite3 //Turn off FreePBX Error Handling $bootstrap_settings['freepbx_error_handler'] = false; require_once('/var/www/html/admin/bootstrap.php'); |
Please note that if you have a module that is using bootstrap, you can do this before bootstrapping as show below:
1 2 3 4 |
//Turn off FreePBX Error Handling$bootstrap_settings['freepbx_error_handler'] = false; if (!@include_once(getenv('FREEPBX_CONF') ? getenv('FREEPBX_CONF') : '/etc/freepbx.conf')) { include_once('/etc/asterisk/freepbx.conf'); } |
The error has gone.