Skip to content

Commit a2ee03c

Browse files
authored
Merge pull request #232 from stellarwp/chore/xdebug-wsl-doc
Add WSL2-specific Xdebug configuration section
2 parents 577d848 + 0a87016 commit a2ee03c

File tree

1 file changed

+77
-1
lines changed

1 file changed

+77
-1
lines changed

docs/xdebug.md

Lines changed: 77 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,80 @@ Here's a standard configuration for Xdebug in VSCode or VSCode-like editors. _(N
6767
In this `launch.json` file, there are two `pathMappings` entries:
6868

6969
1. The first one maps the `slic` plugins directory (left side) to your local WP's plugins directory (right side).
70-
2. The second one is technically optional, but it assumes you've added the `slic` directory to your VSCode workspace and maps the `slic` WP root (left side) to your local `slic` directory's WP root (right side).
70+
2. The second one is technically optional, but it assumes you've added the `slic` directory to your VSCode workspace and maps the `slic` WP root (left side) to your local `slic` directory's WP root (right side).
71+
72+
## WSL2
73+
74+
When using slic on WSL2 (Windows Subsystem for Linux), the default `host.docker.internal` configuration may not work correctly because Docker containers need to connect to the WSL2 host where your code editor is running, not the Windows host.
75+
76+
**Important:** All commands in this section should be run in your WSL2/Ubuntu terminal, not in Windows PowerShell or Command Prompt.
77+
78+
### Step 1: Find your WSL2 IP address
79+
80+
First, identify your WSL2 IP address:
81+
82+
```bash
83+
hostname -I | awk '{print $1}'
84+
```
85+
86+
This will output your WSL2 IP address (e.g., `172.24.206.58`).
87+
88+
### Step 2: Configure Xdebug to use the WSL2 IP
89+
90+
Configure slic's Xdebug to use your WSL2 IP address instead of the default `host.docker.internal`:
91+
92+
```bash
93+
slic xdebug host $(hostname -I | awk '{print $1}')
94+
```
95+
96+
Or manually set it if you know your WSL2 IP:
97+
98+
```bash
99+
slic xdebug host 172.24.206.58
100+
```
101+
102+
**Note:** WSL2 IP addresses can change after restarting WSL2 or Windows, though they often remain stable. If breakpoints stop working, check if your IP has changed and reconfigure if necessary (see [Troubleshooting](#troubleshooting) below).
103+
104+
### Step 3: Restart slic containers
105+
106+
After changing the Xdebug host, restart the slic containers to apply the changes:
107+
108+
```bash
109+
slic restart
110+
slic xdebug on
111+
```
112+
113+
### Step 4: Verify the configuration
114+
115+
Verify that Xdebug is configured correctly:
116+
117+
```bash
118+
slic xdebug status
119+
```
120+
121+
You should see your WSL2 IP address in the "Remote host" field.
122+
123+
### Troubleshooting
124+
125+
If breakpoints still don't work:
126+
127+
1. **Check if your WSL2 IP changed**: WSL2 IP addresses can change after restarting WSL2 or Windows (though they often remain stable). If breakpoints stop working, verify your current IP and reconfigure if it has changed:
128+
```bash
129+
slic xdebug host $(hostname -I | awk '{print $1}')
130+
slic restart
131+
slic xdebug on
132+
```
133+
134+
You can verify your current WSL2 IP with:
135+
```bash
136+
hostname -I | awk '{print $1}'
137+
```
138+
139+
2. **Verify your editor is listening**: Check your editor's debug console to see if there are any connection attempts from Xdebug. In VS Code, go to View → Output → Debug Console. In PHPStorm, check the Debug tool window.
140+
141+
3. **Check Xdebug is enabled**: Make sure Xdebug is enabled in slic:
142+
```bash
143+
slic xdebug on
144+
```
145+
146+
4. **Verify the port**: Ensure port 9001 is not blocked by a firewall and that your code editor is listening on that port.

0 commit comments

Comments
 (0)