Fixing a fatal error with PECL/PEAR with multiple php versions

263 views Asked by At

I need to install a PHP package using PECL on a server. However, I keep getting the following error while executing any pecl or pear command.

PHP Fatal error:  Array and string offset access syntax with curly braces is no longer supported in /usr/share/php/PEAR/Config.php on line 2095

The server is running on Ubuntu 18.04. There is multiple PHP versions installed PHP 7.3, PHP 7.4, and PHP 8.O. The default console PHP version is 8.0. The PEAR version 1:1.10.8.

First, I tried to confirm that the correct PHP version is being used in PECL by: pecl config-set php_suffix=8.0 and trying to view the PECL configuration: pecl show-config. These gave the same error since it uses the Config.php file.

So, I found that there was PHP 8.0 incompatibility with the version of PEAR that is installed. So, I attempted to update the PEAR version to 1.10.12 since there an update that was pending for this version.

However, I ran sudo apt-get install php-pear which gave a dpkg error. So, I executed: sudo dpkg --configure -a which fixed the error. However, then I received the error that broken packages error for linux packages so I executed: apt --fix-broken install.

But now, the updated version of PEAR 1.10.12 was no longer available to install using apt. I have tried:

apt-get update
apt-get upgrade
apt-get install php-pear

But now I get that php-pear is installed to the latest version: 1.10.8.

0

There are 0 answers