Installing Xdebug

Xdebug is a PHP extension that, along with other uses, can capture a profiling log of your PHP script. The steps to install Xdebug depend on your specific environment.

On a Mac

To install Xdebug to your local development environment, open Terminal and type the following command.

sudo pecl install xdebug

We’ll need to add the extension to our php.ini file, but first we need to know where it was installed. Type the following command.

pecl list-files xdebug

You’ll see output similar to this. It’s the .so file we’re interested in. Copy the full path to the file.

Installed Files For xdebug
==========================
Type Install Path
doc  /usr/local/php5/lib/php/doc/xdebug/contrib/tracefile-analyser.php
doc  /usr/local/php5/lib/php/doc/xdebug/contrib/xt.vim
doc  /usr/local/php5/lib/php/doc/xdebug/CREDITS
doc  /usr/local/php5/lib/php/doc/xdebug/LICENSE
doc  /usr/local/php5/lib/php/doc/xdebug/xdebug.ini
doc  /usr/local/php5/lib/php/doc/xdebug/README.rst
src  /usr/local/php5/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so

Next, edit your php.ini file. On Mac this is generally /etc/php.ini, but if you are unsure, create a php file with the line phpinfo() and view it through your browser.

Once you’ve located your php.ini file, add the following lines.

[xdebug]
zend_extension="/full/path/to/xdebug.so"
xdebug.profiler_enable = 0
xdebug.profiler_enable_trigger = 1
xdebug.profiler_enable_trigger_value = "password"
xdebug.profiler_output_dir = "/tmp"
xdebug.profiler_output_name = "cachegrind.out.%p"

On Ubuntu

To install xdebug on a Ubuntu server enter the following command.

sudo apt-get install php-xdebug

Next, edit your php.ini file. On Ubuntu this is generally /etc/php/7.x/apache2/php.ini, but it may not be. If unsure, create a php file with the line phpinfo() and view it through your browser.

Once you’ve located your php.ini file, add the following lines.

[xdebug]
xdebug.profiler_enable = 0
xdebug.profiler_enable_trigger = 1
xdebug.profiler_enable_trigger_value = "password"
xdebug.profiler_output_dir = "/tmp"
xdebug.profiler_output_name = "cachegrind.out.%p"

Keywords

  • Await 1
  • B-Splines 1
  • Bezier 1
  • Binary 1
  • Bluetooth 1
  • Canvas 1 2
  • Curves 1
  • Drupal 1
  • Gulp 1
  • JavaScript 1 2 3
  • PHP 1
  • Promises 1
  • Xdebug 1