$ brew instal [email protected]
$ php -v
# PHP 7.1.29 (cli) (built: May 21 2019 20:05:17) ( NTS )
# Copyright (c) 1997-2018 The PHP Group
# Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
# with Zend OPcache v7.1.29, Copyright (c) 1999-2018, by Zend Technologies
$ php -i | grep extension_dir
# extension_dir => /usr/local/lib/php/pecl/20160303 => /usr/local/lib/php/pecl/20160303
$ pear config-show | grep ext_dir
# PHP extension directory ext_dir /usr/local/lib/php/pecl/20160303
Seems all good, but this will fail.
$ pecl install -f xdebug
# Build process completed successfully
# Installing '/usr/local/Cellar/[email protected]/7.1.29/pecl/20160303/xdebug.so'
# ERROR: failed to mkdir /usr/local/Cellar/[email protected]/7.1.29/pecl/20160303
Make the folder that xdebug wants and make the folder to be writable.
$ sudo mkdir -p /usr/local/Cellar/[email protected]/7.1.29/pecl/20160303
$ sudo chmod 777 /usr/local/Cellar/[email protected]/7.1.29/pecl/20160303
Install again.
$ pecl install -f xdebug
# Build process completed successfully
# Installing '/usr/local/Cellar/[email protected]/7.1.29/pecl/20160303/xdebug.so'
# install ok: channel://pecl.php.net/xdebug-2.7.2
# Extension xdebug enabled in php.ini
We are going to make separate ini file.
First find the ini file and fix it.
php --ini
# Configuration File (php.ini) Path: /usr/local/etc/php/7.1
# Loaded Configuration File: /usr/local/etc/php/7.1/php.ini
# Scan for additional .ini files in: /usr/local/etc/php/7.1/conf.d
# Additional .ini files parsed: /usr/local/etc/php/7.1/conf.d/ext-opcache.ini
Open the Loaded Configuration File
and remove the xdebug line like the following.
$ sudo vim /usr/local/etc/php/7.1/php.ini
-zend_extension="xdebug.so"
[PHP]
;;;;;;;;;;;;;;;;;;;
; About php.ini ;
;;;;;;;;;;;;;;;;;;;
Now let's create a separate ini file for xdebug.
$ sudo vim /usr/local/etc/php/7.1/conf.d/ext-xdebug.ini
+zend_extension=xdebug.so
+xdebug.idekey=IDEA
+xdebug.remote_enable=1
+xdebug.remote_host=host.docker.internal
+xdebug.remote_port=10001
You see with Xdebug v2.7.2
?
$ PHP 7.1.29 (cli) (built: May 21 2019 20:05:17) ( NTS )
# Copyright (c) 1997-2018 The PHP Group
# Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
# with Zend OPcache v7.1.29, Copyright (c) 1999-2018, by Zend Technologies
# with Xdebug v2.7.2, Copyright (c) 2002-2019, by Derick Rethans