Skip to content

Commit acb4fcc

Browse files
authored
[Docs] Move XDebug IDE integration closer to the top, explain the DevTools workflow is highly exploratory (#2975)
Updated the documentation to reflect changes in IDE integration for debugging with Xdebug, including prerequisites and commands for VS Code. Removed redundant sections and clarified the use of experimental flags. cc @fellyph
1 parent 2b0c4df commit acb4fcc

File tree

1 file changed

+46
-42
lines changed

1 file changed

+46
-42
lines changed

packages/docs/site/docs/developers/07-xdebug/02-getting-started.md

Lines changed: 46 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,53 @@ This starts WordPress on `http://127.0.0.1:9400` with Xdebug enabled. Now you ca
3131
Only one project can be debugged at a time.
3232
:::
3333

34-
## Starting with DevTools
34+
## Starting with IDE integration
35+
36+
Similar to the process with DevTools, let's use the same plugin code from before to debug with VS Code, and add the `--experimental-unsafe-ide-integration=vscode` flag. This flag will optimize the setup process for VS Code. If you're working with PhpStorm, add the `--experimental-unsafe-ide-integration=phpstorm` flag.
3537

36-
To debug with Chrome DevTools, add the `--experimental-devtools` flag:
38+
:::info
39+
This flag is marked as `unsafe` because it edits the IDE config files to set Xdebug path mappings and web server details. **CAUTION:** If there are bugs, this feature may cause your IDE configuration files to break. Please consider backing up your IDE configs before using this feature.
40+
:::
41+
42+
To debug in VS Code, you'll need the following prerequisites:
43+
44+
1. An extension to add PHP profiling support, for example, [PHP Debug](https://marketplace.visualstudio.com/items?itemName=xdebug.php-debug) or another debugger extension to your preference.
45+
2. Have a `.vscode/` folder.
46+
3. Enable breakpoints in your IDE. Some IDEs come with this feature disabled, so be aware of this detail.
47+
48+
If everything is ready, you run the command:
49+
50+
```bash
51+
npx @wp-playground/cli@latest server --xdebug --experimental-unsafe-ide-integration=vscode --auto-mount
52+
```
53+
If you don't have a `.vscode/launch.json` file, the terminal will create a file similar to this:
54+
55+
```JSON
56+
{
57+
"configurations": [
58+
{
59+
"name": "WP Playground CLI - Listen for Xdebug",
60+
"type": "php",
61+
"request": "launch",
62+
"port": 9003,
63+
"pathMappings": {
64+
"/": "${workspaceFolder}/.playground-xdebug-root",
65+
"/wordpress/wp-content/plugins/test-xdebug": "${workspaceFolder}/"
66+
}
67+
}
68+
]
69+
}
70+
```
71+
72+
Now, you can go to your code, add the breakpoints, start the debugging session named by your IDE, and happy testing.
73+
74+
![Xdebug in action on VS Code](@site/static/img/developers/xdebug/xdebug-in-action-on-vscode.webp)
75+
76+
## Early Access: DevTools debugger
77+
78+
Playground CLI ships an **unstable, highly exploratory** workflow that enables debugging PHP programs using Chrome DevTools.
79+
80+
To try it, use the `--experimental-devtools` flag:
3781

3882
```bash
3983
npx @wp-playground/cli@latest server --xdebug --experimental-devtools
@@ -99,46 +143,6 @@ The Playground CLI(`@wp-playground/cli`) will automatically detect the plugin fo
99143

100144
![Chrome Devtools integrated with Xdebug](@site/static/img/developers/xdebug/playground-cli-running-xdebug-on-devtools.webp)
101145

102-
## Starting with IDE integration
103-
104-
Similar to the process with DevTools, let's use the same plugin code from before to debug with VS Code, and add the `--experimental-unsafe-ide-integration=vscode` flag. This flag will optimize the setup process for VS Code. If you're working with PhpStorm, add the `--experimental-unsafe-ide-integration=phpstorm` flag.
105-
106-
:::info
107-
This flag is marked as `unsafe` because it edits the IDE config files to set Xdebug path mappings and web server details. **CAUTION:** If there are bugs, this feature may cause your IDE configuration files to break. Please consider backing up your IDE configs before using this feature.
108-
:::
109-
110-
To debug in VS Code, you'll need the following prerequisites:
111-
112-
1. An extension to add PHP profiling support, for example, [PHP Debug](https://marketplace.visualstudio.com/items?itemName=xdebug.php-debug) or another debugger extension to your preference.
113-
2. Have a `.vscode/` folder.
114-
3. Enable breakpoints in your IDE. Some IDEs come with this feature disabled, so be aware of this detail.
115-
116-
If everything is ready, you run the command:
117-
118-
```bash
119-
npx @wp-playground/cli@latest server --xdebug --experimental-unsafe-ide-integration=vscode --auto-mount
120-
```
121-
If you don't have a `.vscode/launch.json` file, the terminal will create a file similar to this:
122146

123-
```JSON
124-
{
125-
"configurations": [
126-
{
127-
"name": "WP Playground CLI - Listen for Xdebug",
128-
"type": "php",
129-
"request": "launch",
130-
"port": 9003,
131-
"pathMappings": {
132-
"/": "${workspaceFolder}/.playground-xdebug-root",
133-
"/wordpress/wp-content/plugins/test-xdebug": "${workspaceFolder}/"
134-
}
135-
}
136-
]
137-
}
138-
```
139-
140-
Now, you can go to your code, add the breakpoints, start the debugging session named by your IDE, and happy testing.
141-
142-
![Xdebug in action on VS Code](@site/static/img/developers/xdebug/xdebug-in-action-on-vscode.webp)
143147

144148
This feature is in experimental mode. Until it's finished, we'll need your feedback. Please connect with us in the [#playground Slack channel](https://wordpress.slack.com/archives/C04EWKGDJ0K) and share your thoughts.

0 commit comments

Comments
 (0)