Sometimes I have to work on our old projects written in PHP. Recently, I am using VS code as my php IDE. VS Code has some great features. I can debug my code easily with XDebug and php-debug VS code extension. But, after upgrading my OS to Ubuntu 16.04, I was facing trouble installing xdebug. Most of the google search refers to php5 XDebug. But, in Ubuntu 16.04 default php version is php7.
So, after searching for a while, I found the solution is pretty simple. Install php-xdebug.
sudo apt-get install php-xdebug
Run the below command in the terminal to ensure xdebug is installed properly. You’ll find xdebug in the list.
php -m
Make sure your php mods-available folder contains xdebug.ini file and this file contains below line:
zend_extension=xdebug.so
Default xdebug.ini location: /etc/php/7.0/mods-available/xdebug.ini
Now, add the below lines at the bottom of your php.ini
file:
[XDebug]
xdebug.remote_enable=1
xdebug.remote_autostart=1
Finally restart apache.
sudo service apache2 restart
And start php-debugging from VS-code.
php-debug, source: https://goo.gl/5nI77s
Thanks.