RK !

Let's make comprehension easy ...

PHP - Debugging

Author: Romaan, Last Updated: Jan. 5, 2021, 6:48 a.m.

In this blog, I would like to share my experience of configuring and setting up PHP debug environment. It is handy when it comes to troubleshooting an issue or understanding an existing PHP based application. Also it is better to place breakpoints and step through the code rather than putting log statements in your development environment.

So below are the software(s) installed:

  • Ubuntu 16.10 Operating System
  • XAMPP server
  • PHP-debugger
  • JetBrains PHP Storm IDE

I will not get into describing how to install ubuntu 16.10 os, as I assume that reader has a basic knowledge of installing and using Ubuntu os.

Inorder to install the PHP debugger, using package manager: 

apt-get install -y php7.0 php7.0-mysql php7.0-dev

Then execute the below commands:

wget http://xdebug.org/files/xdebug-2.5.3.tgz
tar -xvf xdebug-2.5.3
cd xdebug-2.5.3
make test
cp modules/xdebug.so /usr/lib/php/20151012

Next up, download XAMPP server preferably with PHP 7.1.1 for Linux.

Ensure you give the download .run file user executable permission:

chmod u+x <xampp>.run

Then run the following command to start the installation: 

sudo ./xampp-linux-x64-7.0.15-0-installer.run --mode text # Follow default Y options and hit ENTER and the lampp will be installted in /opt/lampp

Stop the instance of lamp if it is running: 

sudo kill -9 `sudo lsof -i :80 | grep lamp | cut -d" " -f2`

Open the file /opt/lampp/etc/php.ini and add the following file:

zend_extension = /usr/lib/php/20151012/xdebug.so  

Start the xampp server by running /opt/lampp/manager-linux-x64.run and visit localhost. Click on PhpInfo on top right. This should show you the PHP configuration. Observe the Zend extension states that xdebug is enabled or alternatively run /opt/lamp/bin/php -m and ensure Zend module has xdebug listed.

Configure your apache configuration to host multiple sites by editing the httpd.conf file as below:

<VirtualHost *:8080>
    ServerAdmin romaank@gmail.com
    ServerName somehostname.com
    <Directory /home/romaan/workspacepy/path/name>
        Options None FollowSymLinks
        AllowOverride All
        Require all granted
    DocumentRoot /home/romaan/athname.log
    ErrorLog /home/romaan/pathname.log
    CustomLog /home/romaan/pathname.log combined

Download Jet Brains PHP Storm IDE

In PHP storm configuration, create a server and add remotely debug PHP application, enter the KEY (PHPSTORM) and that is it :)

Popular Tags:


By: Stas (Aug. 25, 2018, 1:46 a.m.)
I like to use xDebug with CodeLobster IDE: http://www.codelobster.com