Skip to content

Instantly share code, notes, and snippets.

@rockschtar
Last active June 4, 2024 16:38
Show Gist options
  • Save rockschtar/93a892a7065be425a4729e2690648150 to your computer and use it in GitHub Desktop.
Save rockschtar/93a892a7065be425a4729e2690648150 to your computer and use it in GitHub Desktop.
Windows 10/11 + WSL2 + Docker + Lando + PHP XDebug (PHPStorm, IntelliJ & Visual Studio Code (vscode))
  1. Install WSL
  2. Install your preferred WSL Linux Distro vom Microsoft Store. In my case I used Ubuntu 20.04.
  3. Install Docker for Windows
  4. Enable Docker WSL2 Integration image
  5. Install Lando inside WSL
wget https://github.com/lando/lando/releases/download/v3.6.0/lando-x64-v3.6.0.deb
dpkg -i --ignore-depends=docker-ce lando-x64-v3.6.0.deb
  1. Remove docker-ce dependency from Lando in /var/lib/dpkg/status. Otherwise you would have problems install other packages via apt
sudo nano /var/lib/dpkg/status 

image

  1. Configure Lando for XDebug in your WSL.
  • Create a file named .lando.local.yml in your project root folder (Same location as .lando.yml) with the content below. Also add .lando.local.yml to your .gitignore. See Landofile Documentation for more information.

.lando.local.yml:

services:
 appserver:
   overrides:
     environment:
       XDEBUG_CONFIG: "discover_client_host=0 client_host=host.docker.internal"
  1. (PHPStorm & IntelliJ only) Add a "PHP Web Page" "Run/Debug Configuration" and set up your path mappings correctly (Normally map your project root folder to path "/app" on the server)
  2. (Visual Studio Code only) Launch configuration (Replace the hostname value with your .lndo.site URL hostname)
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Listen for Xdebug",
            "hostname": "yoursite.lndo.site",
            "type": "php",
            "request": "launch",
            "port": 9003,
            "pathMappings": {
                "/app": "${workspaceRoot}",
              },
              "log": true,
        }
}
  1. Enjoy high performance disk I/O and XDebug working with Windows, Lando, Docker and WSL2!
@HassanNawazHiraj
Copy link

Thanks man. My xdebug was broken for months for some reason. Was not able to fix. Adding your local lando + launch file fixed the problem.

@superromeo
Copy link

superromeo commented Aug 2, 2023

It works! Thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment