One summer beautiful day I updated PHP from 7.4 to 8.0 and PHPStorm from 2019.3 to 2021.3 on my work station.
I used xDebug v2.9.8 from PECL on PHP 7.4 and xDebug v3.1.2 from Ubuntu repository ppa:ondrej/php on PHP 8.0
I wanted to preserve different version xDebug on different version PHP. Do not tell me Why :-)
This script build xDebug from PECL for PHP 7.4. Example usage:
./pecl-php-package-installer.sh 7.4 xdebug 2.9.8
You may use this code for building necessary version of xDebug or other PECL package on target PHP version.
However, if you will try to build the different version of the same package on different target PHP, the previous build of package was purged.
I not found the reason. Tell me if you know.
I build xDebug v2.9.8 for PHP 7.4 using this script and install xDebug v3.1.2 from apt.
Final result:
# ./pecl-php-package-installer.sh 7.4 xdebug 2.9.8
# php7.4 -v
PHP 7.4.30 (cli) (built: Aug 1 2022 15:06:20) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.30, Copyright (c), by Zend Technologies
with Xdebug v2.9.8, Copyright (c) 2002-2020, by Derick Rethans
# apt install php8.0-xdebug
# php8.0 -v
PHP 8.0.21 (cli) (built: Aug 1 2022 07:40:52) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.21, Copyright (c) Zend Technologies
with Zend OPcache v8.0.21, Copyright (c), by Zend Technologies
with Xdebug v3.1.2, Copyright (c) 2002-2021, by Derick Rethans
P.S.: I got all what I wanted and back to the job.