Linux Mint + XAMPP + How To Install Xdebug Extension For PHP

Assumptions

  • You are using a linux distro, in my instance I’m using Linux Mint, but this is applicable to any deb-based linux for example Ubuntu or Debian
  • Your LAMP Stack is XAMPP
  • You are familiar with using phpize and can install it
  • You know how to configure your web server

Overview

Installing the xdebug extension has never been so simple, with the nice features and hard-work that Derick Rethans (Creator of Xdebug) has done. We will use his install wizard for this installation.

(PS: I recently did an interview with Derick Rethans, read it here!)

Installation STEPS:

  • Open your browser & get the output from phpinfo(); copy and paste the whole HTML source code into the textarea of the Xdebug Wizard. (NOTE: It says to not paste the raw HTML source, but it worked for me. But in case for you it doesn’t, paste the browser output as-is)
  • Now the rest of the steps is just to follow the steps of the result generated by the wizard, mine looked like below:
xdebug install - Wizard Output
xdebug install – Wizard Output

The Rest Of The Steps I Did..

      1. Download the .tgz compressed source of xdebug as given in the #1 instruction from the wizard, for me the file was named: xdebug-2.2.1.tgz. (Note: I downloaded it to /Desktop/xdebug/)
      2. Do $ sudo tar -xvzf xdebug-2.2.1.tgz //To Extract it using Terminal
      3. Do $ cd xdebug-2.2.1 //To navigate to the inner forlder xdebug-2.2.1 from the extracted file
      4. Do $ sudo /opt/lampp/bin/phpize //You need to run phpize – This resides in /opt/lampp/bin/phpizeIf successful, you should see an output as below:

        phpize output
        phpize output
      5. Do $ sudo ./configure –enable-xdebug –with-php-config=/opt/lampp/bin/php-config
      6. Do $ sudo make
      7. Do $ cp modules/xdebug.so /opt/lampp/lib/php/extensions/no-debug-non-zts-20100525 – //We are copying the generated xdebug extension to XAMPP’s php extensions’ folder
      8. Add the following line to your php.ini file zend_extension = /opt/lampp/lib/php/extensions/no-debug-non-zts-20100525/xdebug.soNOTE: php.ini is found here: /opt/lampp/etc/php.ini
      9. $ sudo /opt/lampp/lampp restart – Restart your webserver

php.ini configuration for using Xdebug

I’m quite comfortable with the following settings:

[zend]
zend_extension=”/opt/lampp/lib/php/extensions/no-debug-non-zts-20100525/xdebug.so”

[xdebug]
xdebug.extended_info=1
xdebug.max_nesting_level=1000
xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = 1
xdebug.remote_enable=1
xdebug.remote_host = “127.0.0.1”
xdebug.idekey=”netbeans-xdebug” (set it to PHPSTORM is you are using that ide)
xdebug.remote_port=9000
xdebug.remote_handler = “dbgp”
xdebug.remote_mode = “req”
xdebug.remote_log=”/[someFolder]/error_log/xdebug.log”
xdebug.show_local_vars=1
xdebug.trace_output_dir = “/opt/lampp/tmp”
xdebug.var_display_max_data=1000
xdebug.var_display_max_depth=1

Pitfalls – configure: error: Cannot find php-config. Please use –with-php-config=PATH

I initially had the error message: “configure: error: Cannot find php-config. Please use –with-php-config=PATH

That occurred because I did not specify a path for php-config, that is I did $ sudo ./configure instead of $ sudo ./configure –enable-xdebug –with-php-config=/opt/lampp/bin/php-config

 

Voila! All set! Get back to your coding! 🙂

You might want to check the following related issues also:


1 Comment(s)



Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.