PHP debugging on Ubuntu

M
Mar 15, 2021

--

Assumption

  1. Ubuntu 20.04.2 LTS
  2. PHP 7.4.3 (see installation on Ubuntu https://linuxize.com/post/how-to-install-php-on-ubuntu-20-04/)
  3. Xdebug v2.9.2 (see installation on Ubuntu https://xdebug.org/docs/install#linux)
  4. Use Visual studio code as IDE
  5. Already Installed php debug, the Visual studio code extension (see install guide https://marketplace.visualstudio.com/items?itemName=felixfbecker.php-debug)
  6. (optional) Already install vim (see installation guide https://www.vim.org/download.php#unix)

First thing first, navigate to

cd /etc/php/7.4/mods-available

Then edit the file xdebug.ini with sudo

sudo vim /etc/php/7.4/mods-available/xdebug.ini

Then paste these line to the file /etc/php/7.4/mods-available/xdebug.ini

zend_extension=/usr/lib/php/20190902/xdebug.so
xdebug.remote_autostart = 1
xdebug.remote_enable = 1
xdebug.remote_handler = dbgp
xdebug.remote_host = 127.0.0.1
xdebug.remote_log = /tmp/xdebug_remote.log
xdebug.remote_mode = req

Done !!!

--

--

M
M

Written by M

Web Developer at Thaibev PLC.

No responses yet