Skip to content

Commit 1e58277

Browse files
committed
Add "Setting Xdebug" section in PHP docs
The page about PHP in the docs doesn’t explain how to use Xdebug. I had a lof of trouble setting it up the first time, then recently had another headache trying to get it to work again, because the value for `adapter` had changed from `PHP` to `Xdebug`.
1 parent 45a0d08 commit 1e58277

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

docs/src/languages/php.md

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ The PHP extension offers both `phpactor` and `intelephense` language server supp
1313

1414
`phpactor` is enabled by default.
1515

16-
## Phpactor
16+
### Phpactor
1717

1818
The Zed PHP Extension can install `phpactor` automatically but requires `php` to be installed and available in your path:
1919

@@ -25,7 +25,7 @@ The Zed PHP Extension can install `phpactor` automatically but requires `php` to
2525
which php
2626
```
2727

28-
## Intelephense
28+
### Intelephense
2929

3030
[Intelephense](https://intelephense.com/) is a [proprietary](https://github.com/bmewburn/vscode-intelephense/blob/master/LICENSE.txt#L29) language server for PHP operating under a freemium model. Certain features require purchase of a [premium license](https://intelephense.com/).
3131

@@ -60,3 +60,35 @@ To use the premium features, you can place your [licence.txt file](https://intel
6060
Zed supports syntax highlighting for PHPDoc comments.
6161

6262
- Tree-sitter: [claytonrcarter/tree-sitter-phpdoc](https://github.com/claytonrcarter/tree-sitter-phpdoc)
63+
64+
## Setting up Xdebug
65+
66+
Zed’s PHP extension provides a debug adapter for PHP and Xdebug. The adapter name is `Xdebug`. Here a couple ways you can use it:
67+
68+
```json
69+
[
70+
{
71+
"label": "PHP: Listen to Xdebug",
72+
"adapter": "Xdebug",
73+
"request": "launch",
74+
"initialize_args": {
75+
"port": 9003
76+
}
77+
},
78+
{
79+
"label": "PHP: Debug this test",
80+
"adapter": "Xdebug",
81+
"request": "launch",
82+
"program": "vendor/bin/phpunit",
83+
"args": ["--filter", "$ZED_SYMBOL"]
84+
}
85+
]
86+
```
87+
88+
In case you run into issues:
89+
90+
- ensure that you have Xdebug installed for the version of PHP you’re running
91+
- ensure that Xdebug is configured to run in `debug` mode
92+
- ensure that Xdebug is actually starting a debugging session
93+
- check that the host and port matches between Xdebug and Zed
94+
- look at the diagnostics log by using the `xdebug_info()` function in the page you’re trying to debug

0 commit comments

Comments
 (0)