Igor Simic
3 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,

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: 

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: 

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