Wednesday, September 2, 2015

How to enable PHP debugging with XAMPP for Linux and XDebug

Peace be upon you.. I decide to learn debugging PHP web application using XAMPP for Linux and XDebug. This tutorial are based from XAMPP for Linux 5.6.11, but it suppose will be valid in future because I using xdebug that provided with the XAMPP and I just enable it.

Let's check our PHP installation with php --version command
$ php --version
PHP 5.6.11 (cli) (built: Aug 10 2015 20:47:04) 
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies
    with Xdebug v2.2.5, Copyright (c) 2002-2014, by Derick Rethans
* Note : If the output said about Xdebug version, it mean you PHP already debug enable and else are not enable yet.

The another way to check is to read from PHP info, just create a new file with code below and execute from our localhost:
<?php phpinfo() ?>
* Note : Find "xdebug" using ctrl+f and if you found this section it mean you PHP already debug enable and else are not enable yet.

Now, I assume our PHP does not enable Xdebug yet.. and we are going to enable it by edit /opt/lampp/etc/php.ini file
$ gksudo  gedit /opt/lampp/etc/php.ini
Add this line inside that file :
zend_extension = /opt/lampp/lib/php/extensions/no-debug-non-zts-20131226/xdebug.so
And now, restart the server and after that we can run / debug the PHP web application :
$ sudo /opt/lampp/xampp restart
So easy right? That all we need, Thanks.

No comments:

Post a Comment