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:
The Rest Of The Steps I Did..
- 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/)
- Do $ sudo tar -xvzf xdebug-2.2.1.tgz //To Extract it using Terminal
- Do $ cd xdebug-2.2.1 //To navigate to the inner forlder xdebug-2.2.1 from the extracted file
- 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:
- Do $ sudo ./configure –enable-xdebug –with-php-config=/opt/lampp/bin/php-config
- Do $ sudo make
- 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
- 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
- $ 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! 🙂
I finally succeeded, after much hatred. Php sucks because of that.