Debugging on Laravel Homestead using VS Code

Edit the Xdebug ini file in your Vagrant Homestead box:-

cd /etc/php/7.2/mods-available
sudo nano xdebug.ini

Make sure the contents look like this:-
xdebug.remote_enable = 1
xdebug.remote_connect_back = 1
xdebug.remote_port = 9000
xdebug.idekey = VSCODE
xdebug.remote_autostart = 1
xdebug.max_nesting_level = 512

The important settings are the idekey and remote_autostart.

Then restart FPM-PHP with the following command:-

sudo service php7.2-fpm restart

If you’re using PHP 7.3, just modify the command as required.

Your VS Code debug config file should look something like this:-

    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit:
    "version": "0.2.0",
    "configurations": [
            "name": "Listen for XDebug",
            "type": "php",
            "request": "launch",
            "port": 9000,
            "pathMappings": {
                "/home/vagrant/app": "${workspaceRoot}",

            "name": "Launch currently open script",
            "type": "php",
            "request": "launch",
            "program": "${file}",
            "cwd": "${fileDirname}",
            "port": 9000

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top