1051 1624 1954 1881 1455 1697 1199 1738 1921 1009 1881 1562 1167 1236 1315 1555 1049 1282 1501 1559 1464 1978 1234 1154 1992 1144 1986 1019 1850 1453 1945 1133 1204 1792 1681 1176 1155 1184 1723 1225 1206 1912 1458 1743 1195 1620 1653 1693 1519 1749 1290 1688 1613 1165 1084 1097 1238 1232 1997 1343 1534 1705 1116 1992 1837 1115 1661 1296 1154 1754 1584 1243 1510 1732 1810 1894 1097 1028 1971 1835 1242 1948 1037 1635 1316 1683 1046 1350 1581 1694 1744 1371 1242 1236 1601 1717 1444 1831 1290 Installing Xdebug on PHP 8.1 installed with Homebrew | PHPnews.io

PHPnews.io

Installing Xdebug on PHP 8.1 installed with Homebrew

Written by Rob Allen / Original link on Jul. 26, 2022

I have recently set up a new M2 MacBook Air and as usual, installed Homebrew and then installed PHP. Homebrew is always up to date, so it installed PHP 8.1 for me.

Again, as usual, I installed Xdebug using pecl install xdebug.

This whirrs and clicks for a while downloading and compiling the xdebug.so and then fails with:

rob@ardent ~ $ pecl install xdebug
downloading xdebug-3.1.5.tgz ...
Starting to download xdebug-3.1.5.tgz (232,070 bytes)

...

Build process completed successfully
Installing '/opt/homebrew/Cellar/php/8.1.8/pecl/20210902/xdebug.so'

PHP Warning:  mkdir(): File exists in /opt/homebrew/Cellar/php/8.1.8/share/php/pear/System.php on line 294
ERROR: failed to mkdir /opt/homebrew/Cellar/php/8.1.8/pecl/20210902

Investigating, I found that /opt/homebrew/Cellar/php/8.1.8/pecl is a symlink to /opt/homebrew/lib/php/pecl, however, this directory doesn't exist. So to fix, I created the directory and installed Xdebug again:

mkdir /opt/homebrew/lib/php/pecl
pecl install xdebug

This time it worked:

rob@ardent ~ $ pecl install xdebug
downloading xdebug-3.1.5.tgz ...
Starting to download xdebug-3.1.5.tgz (232,070 bytes)

...

Build process completed successfully
Installing '/opt/homebrew/Cellar/php/8.1.8/pecl/20210902/xdebug.so'
install ok: channel://pecl.php.net/xdebug-3.1.5
Extension xdebug enabled in php.ini

A quick test shows that all is now as it should be:

rob@ardent ~ $ php -v
PHP 8.1.8 (cli) (built: Jul  8 2022 10:46:35) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.8, Copyright (c) Zend Technologies
    with Xdebug v3.1.5, Copyright (c) 2002-2022, by Derick Rethans
    with Zend OPcache v8.1.8, Copyright (c), by Zend Technologies

roballen roballen roballen

« Global Writable Stores - Efficient Pagination Using Deferred Joins »