Igor Simic
4 years ago

Install PHP with xdebug on Mac OS and enable xdebug on PhpStorm


How to install xdebug on your local version of Mac OS PHP and enable it in PhpStorm for local development? In this tutorial we will explain you how.


Install xdebug on your MAC OS CATALINA

In order to use xdebug we have to install it. There is a lot of tutorials on the internet, but i found this process easiest.
Actually we will update our local version of PHP with the latest PHP version with included xdebug (and bunch of others extensions: zip, redis, curl...).
Detailed steps how to do that you can find here 

After we updated our php version, make sure that we have xdebug installed:
php -m
if you can not see the extension, make sure that you are using newly installed version:
php -v
if you still do not see the newly installed PHP version, use this command:
export PATH=/usr/local/php5/bin:$PATH

after this you should see this (in our case we have installed PHP 7.3.8 version):


PHP version 7.3 with xdebug installed



ok, now if you type php -m you should see xdebug on the list

Set up XDEBUG with PhP Storm

FInd your PHP ini settings for xdebug, type:
php --ini

You should get the list of php ini file used for your instance of PHP:
Configuration File (php.ini) Path: /usr/local/php5/lib
Loaded Configuration File:         /usr/local/php5/lib/php.ini
Scan for additional .ini files in: /usr/local/php5/php.d
Additional .ini files parsed:      /usr/local/php5/php.d/10-extension_dir.ini,
/usr/local/php5/php.d/20-extension-opcache.ini,
/usr/local/php5/php.d/40-curl.ini,
/usr/local/php5/php.d/40-openssl.ini,
/usr/local/php5/php.d/50-extension-apcu.ini,
/usr/local/php5/php.d/50-extension-curl.ini,
/usr/local/php5/php.d/50-extension-gmp.ini,
/usr/local/php5/php.d/50-extension-igbinary.ini,
/usr/local/php5/php.d/50-extension-imap.ini,
/usr/local/php5/php.d/50-extension-intl.ini,
/usr/local/php5/php.d/50-extension-mcrypt.ini,
/usr/local/php5/php.d/50-extension-mongodb.ini,
/usr/local/php5/php.d/50-extension-mssql.ini,
/usr/local/php5/php.d/50-extension-pdo_pgsql.ini,
/usr/local/php5/php.d/50-extension-pgsql.ini,
/usr/local/php5/php.d/50-extension-propro.ini,
/usr/local/php5/php.d/50-extension-raphf.ini,
/usr/local/php5/php.d/50-extension-readline.ini,
/usr/local/php5/php.d/50-extension-redis.ini,
/usr/local/php5/php.d/50-extension-xdebug.ini,
/usr/local/php5/php.d/50-extension-xsl.ini,
/usr/local/php5/php.d/99-liip-developer.ini



List of PHP.ini files



Select usr/local/php5/php.d/50-extension-xdebug.ini and open it with command:
sudo nano /usr/local/php5/php.d/50-extension-xdebug.ini

And make sure that you have these lines inside of that xdebug ini file: 

zend_extension=/usr/local/php5/lib/php/extensions/no-debug-non-zts-20180731/xdebug.so
[xdebug]
xdebug.remote_enable=on
xdebug.default_enable=on
xdebug.remote_autostart=off
xdebug.remote_port=9000
xdebug.remote_host=localhost
xdebug.profiler_enable_trigger=1
xdebug.profiler_output_name=xdebug-profile-cachegrind.out-%H-%R
xdebug.var_display_max_children = 128
xdebug.var_display_max_data = 512
xdebug.var_display_max_depth = 3
xdebug.remote_enable = 1
xdebug.idekey = PHPSTORM
xdebug.show_error_trace = 1
xdebug.file_link_format = phpstorm://open?%f:%l


After that, our xdebug should be set.

Now let's go to PhpStorm and make some settings there. Go to  Settings/Preferences dialog ⌘,, select Languages & Frameworks | PHP
Here the settings should look like this:



PhP Storm settings for xdebug


Update your Automatically detect IDE IP if needed, and press OK

Install Xdebug helper to your Chrome browser: 
https://chrome.google.com/webstore/detail/xdebug-helper/eadndfjplgieldjbigjakmdgkmoaaaoc



Do not forget to enable "Start listening for debug connections"


Enable Start listening for debug connections



And that is it

If you don't know how to install xdebug with PhpStorm
Now you know