Skip to content

Instantly share code, notes, and snippets.

@ascorbic-acid
Created September 3, 2021 04:25
Show Gist options
  • Save ascorbic-acid/2cd9685d6e37b6d0176456d085883736 to your computer and use it in GitHub Desktop.
Save ascorbic-acid/2cd9685d6e37b6d0176456d085883736 to your computer and use it in GitHub Desktop.
VSCode XDebug with php 7.4 fpm
first install xdebug:
sudo apt-get install php7.4-xdebug
edit config file with the following, also check the zend version (20190902) if it is different on your machine:
sudo nano /etc/php/7.4/mods-available/xdebug.ini
zend_extension="/usr/lib/php/20190902/xdebug.so"
xdebug.mode = debug
xdebug.start_with_request = yes
xdebug.discover_client_host = 1
xdebug.remote_handler = dbgp
xdebug.remote_host = 127.0.0.1
xdebug.remote_log = /tmp/xdebug_remote.log
xdebug.remote_mode = req
xdebug.remote_port = 9099
restart the service
sudo service php7.4-fpm restart
install VSCode PHP Debug extenstion by Felix Becker and create new debug file with the following
"configurations": [
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 9003
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 0,
"runtimeArgs": [
"-dxdebug.start_with_request=yes"
],
"env": {
"XDEBUG_MODE": "debug,develop",
"XDEBUG_CONFIG": "client_port=${port}"
}
},
{
"name": "Launch Built-in web server",
"type": "php",
"request": "launch",
"runtimeArgs": [
"-dxdebug.mode=debug",
"-dxdebug.start_with_request=yes",
"-S",
"localhost:9999"
],
"program": "",
"cwd": "${workspaceRoot}",
"port": 9003,
"serverReadyAction": {
"pattern": "Development Server \\(http://localhost:([0-9]+)\\) started",
"uriFormat": "http://localhost:%s",
"action": "openExternally"
}
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment