Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Enea74's avatar

Xdebug + Homestead + Laravel + PHP 8.0 + VSCode

I'm struggling to make Xdebug work on Laravel/Homestead using VSCode as IDE and after a couple of hours trying I think I need some help.

Here is what I get with php -v on the vagrant machine:

PHP 8.0.0 (cli) (built: Nov 27 2020 12:26:05) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.0-dev, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.0, Copyright (c), by Zend Technologies
    with Xdebug v3.0.0beta1, Copyright (c) 2002-2020, by Derick Rethans

Here is the Xdebug loaded .ini file:

php --ini | grep xdebug
/etc/php/8.0/cli/conf.d/20-xdebug.ini,

Here is the 20-xdebug.ini file:

zend_extension=xdebug.so
# xdebug.remote_enable = 1
xdebug.mode = debug
# xdebug.remote_connect_back = 1
xdebug.discover_client_host = yes
#xdebug.remote_port = 9000
xdebug.client_port = 9000
xdebug.idekey = VSCODE
xdebug.max_nesting_level = 512
# xdebug.remote_autostart = 1
xdebug.start_with_request = yes
# xdebug.remote_host = 10.0.2.2
xdebug.client_host = 10.0.2.2

Important: the syntax has almost completely changed since Xdebug 3.0, (see https://xdebug.org/docs/upgrade_guide ) so I commented out the deprecated options (otherwise I will get tons of warnings when firing php -v for instance)

Here is my launch.json file on VSCode:

{
  // Use IntelliSense to learn about possible attributes.
  // Hover to view descriptions of existing attributes.
  // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Listen for XDebug",
      "type": "php",
      "request": "launch",
      "port": 9000
    },
    {
      "name": "Launch currently open script",
      "type": "php",
      "request": "launch",
      "program": "${file}",
      "cwd": "${fileDirname}",
      "port": 9000
    },
    {
        "name": "Listen for XDebug on Homestead",
        "type": "php",
        "request": "launch",
        "pathMappings": {
            "/home/vagrant/my-project": "${workspaceRoot}"
        },
        "port": 9000
    }
  ]
}

So basically when debugging with the "Listen for XDebug on Homestead" it simply does not stop at any breakpoint and the "Everything" option doesn't work either.

What I'm missing?

0 likes
2 replies
ventoh's avatar

Xdebug 3 has switched default listen port from 9000 to 9003

trogne's avatar

Xdebug 3 changed some config names :

https://xdebug.org/docs/upgrade_guide

This works for me :

zend_extension=xdebug.so
#xdebug.remote_enable = 1 # DEPRECATED
xdebug.mode=debug
#xdebug.remote_connect_back = 1  # DEPRECATED
xdebug.discover_client_host=1
#xdebug.remote_port = 9000  # DEPRECATED
xdebug.client_port = 9000
xdebug.max_nesting_level = 512
#xdebug.idekey=VSCODE
#xdebug.remote_host=10.0.2.2  # DEPRECATED
xdebug.client_host=10.0.2.2 # host used as fallback if host not found with xdebug.discover_client_host
#xdebug.remote_autostart=1  # DEPRECATED
xdebug.start_with_request=yes # together with xdebug.mode=debug, if don't want to add ?XDEBUG_SESSION_START=0 to the url

1 like

Please or to participate in this conversation.