download on the mac app store

Treemap, Callgraph, Heatmap, Call tree, Print and PDF, Annotated sourcefile viewer. Combine multiple metrics into one chart. Suppress functions based on the source file path.

The new Xdebug 2.6 (and later) added support for memory profiling php scripts. Profiling Viewer already handles multiple types of costs. Just open the generated file and select between Time and Memory costs types.

show more...

How to install Xdebug on MacOS Mojave (and High Sierra)

MacOS High Sierra and Mojave comes with a preinstalled xdebug, unfortunately, if you try to use it you will get errors like these:


Symbol not found: _xdebug_monitored_function_dtor
					

PHP Warning:  Method xdebug_start_function_monitor() cannot be a NULL 
    function in Unknown on line 0
    PHP Warning:  xdebug: Unable to register functions, unable to load in Unknown on line 0
    Segmentation fault: 11
					

To Fix this, you have to compile xdebug on your own. Here is how:

Download xdebug from Xdebug.org and extract the archive.


tar xzf xdebug-2.7.0.tgz
cd xdebug-2.7.0
					

Now, run phpize.

phpize

When everything went good, you get something like this:


Configuring for:
PHP Api Version:         20170718
Zend Module Api No:      20170718
Zend Extension Api No:   320170718
					

If so, you can skip the next part and continue with configuring and installing Xdebug.

Errors like these means, you need to install some requirements.


grep: /usr/include/php/main/php.h: No such file or directory
grep: /usr/include/php/Zend/zend_modules.h: No such file or directory
grep: /usr/include/php/Zend/zend_extensions.h: No such file or directory
Configuring for:
PHP Api Version:        
Zend Module Api No:     
Zend Extension Api No:  
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.
					

When the xcode commandline tools is not installed, phpize complains about missing include files. You can fix this with installing xcode commandline tools.


grep: /usr/include/php/main/php.h: No such file or directory
grep: /usr/include/php/Zend/zend_modules.h: No such file or directory
grep: /usr/include/php/Zend/zend_extensions.h: No such file or directory
					

This can be done with the following command:

xcode-select --install

Follow the instuctions and wait until MacOS downloads and installs the package.

If that not helps, you can try to reinstall the header files

sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /

Follow the instuctions and wait until MacOS downloads and installs the package.

If phpize prints lines like these, you need to install autoconf:


Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.
					

To install autoconf, execute the following commands:


#create a new directory
cd ..
mkdir mybuilddir
cd mybuilddir

#dowload autoconf
curl -OL http://ftpmirror.gnu.org/autoconf/autoconf-2.69.tar.gz

#extract it, and change into the folder
tar xzf autoconf-2.69.tar.gz
cd autoconf-2.69

#now build and install it
./configure --prefix=/usr/local
make
sudo make install

#change back to the xdebug folder
cd ..
cd xdebug-2.7.0
					

Now run phpize again.

phpize

Check the output, and if everything went good, continue.


Configuring for:
PHP Api Version:         20170718
Zend Module Api No:      20170718
Zend Extension Api No:   320170718
					

Configure and build xdebug:


./configure
make
					

We don't executing "make install" to install xdebug.so because the macOS System Integrity Protection (SIP) will not allow us to install xdebug to the /urs/lib/extensions folder. To workaround this, we install the extension under the /usr/local folder.


mkdir -p /usr/local/php/extensions
cp modules/xdebug.so /usr/local/php/extensions
					

Now edit your php.ini to load the right xdebug. PHP searches for extensions in its default extension directory. Our xdebug resides outside of this directory, so we have to spefify the full path:


zend_extension=/usr/local/php/extensions/xdebug.so
					

To test it, execute:


php -i | grep xdebug
					

The output should begin like this:


xdebug
xdebug support => enabled
....
					

For opening profiling files generated by xdebug on MacOS, my app Profiling Viewer can come in handy. Take a look at Profiling Viewer