Skip to content

Commit 5485a3c

Browse files
authored
feat: support XDebug v3 (#435)
* ci: support XDebug v3 * docs: update readme * ci: don't run test twice * ci: make builds easier to read * ci: use matrix.include * ci: set port to 9000 * docs: document port 9000 setting * test: use trigger_error() Many error cases were reclassified in PHP 8. * docs: update port docs * ci: run matrix on new version
1 parent bdfebbe commit 5485a3c

4 files changed

Lines changed: 31 additions & 16 deletions

File tree

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ insert_final_newline = true
77
end_of_line = lf
88
charset = utf-8
99

10-
[{*.json,*.yml,.prettierrc}]
10+
[{*.json,*.yml,.prettierrc,*.md}]
1111
indent_size = 2
1212

1313
[*.md]

.github/workflows/build.yml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ env:
77

88
jobs:
99
test:
10+
if: github.event_name == 'pull_request' || github.ref == 'refs/heads/main'
1011
runs-on: ${{ matrix.os }}
1112
strategy:
1213
matrix:
13-
os:
14-
- ubuntu-18.04
15-
- windows-2019
16-
- macos-10.15
17-
xdebug:
18-
- '2.9.8'
19-
php:
20-
- '7.4'
14+
include:
15+
# Latest version
16+
- { xdebug: xdebug-3.0.1, php: '8.0', os: ubuntu-18.04 }
17+
- { xdebug: xdebug-3.0.1, php: '8.0', os: windows-2019 }
18+
- { xdebug: xdebug-3.0.1, php: '8.0', os: macos-10.15 }
19+
# Old versions
20+
- { xdebug: xdebug-2.9.8, php: '7.4', os: ubuntu-18.04 }
2121
steps:
2222
- uses: actions/checkout@v2
2323
- name: Setup Node.js
@@ -36,8 +36,14 @@ jobs:
3636
uses: shivammathur/setup-php@v2
3737
with:
3838
php-version: ${{ matrix.php }}
39-
extensions: xdebug-${{ matrix.xdebug }}
39+
extensions: ${{ matrix.xdebug }}
40+
# Top: XDebug v3
41+
# Bottom: XDebug v2
4042
ini-values: >-
43+
xdebug.mode = debug,
44+
xdebug.start_with_request = yes,
45+
xdebug.client_port = 9000,
46+
4147
xdebug.remote_enable = 1,
4248
xdebug.remote_autostart = 1,
4349
xdebug.remote_log = /tmp/xdebug.log

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,22 @@ This extension is a debug adapter between VS Code and [XDebug](https://xdebug.or
2020

2121
3. Enable remote debugging in your `php.ini`:
2222

23+
For XDebug v3.x.x:
24+
25+
```ini
26+
xdebug.mode = debug
27+
xdebug.start_with_request = yes
28+
xdebug.client_port = 9000
29+
```
30+
31+
For XDebug v2.x.x:
32+
2333
```ini
24-
[XDebug]
2534
xdebug.remote_enable = 1
2635
xdebug.remote_autostart = 1
2736
```
2837

29-
There are other ways to tell XDebug to connect to a remote debugger than `remote_autostart`, like cookies, query parameters or browser extensions. I recommend `remote_autostart` because it "just works". There are also a variety of other options, like the port (by default 9000), please see the [XDebug documentation on remote debugging](https://xdebug.org/docs/remote#starting) for more information.
38+
There are other ways to tell XDebug to connect to a remote debugger, like cookies, query parameters or browser extensions. I recommend `remote_autostart` (XDebug v2)/`start_with_request` (XDebug v3) because it "just works". There are also a variety of other options, like the port, please see the [XDebug documentation on remote debugging](https://xdebug.org/docs/remote#starting) for more information. Please note that the default XDebug port changed between XDebug v2 to v3 from 9000 to 9003. The extension still defaults to 9000, so make sure your configuration in `launch.json` and `php.ini` match.
3039

3140
4. If you are doing web development, don't forget to restart your webserver to reload the settings.
3241

testproject/error.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
$array = array('hello' => 'world');
44

5-
// Notice (undefined index)
6-
echo $array['undefined_index'];
5+
// Notice
6+
trigger_error("Test notice", E_USER_NOTICE);
77

8-
// Warning (illegal offset type)
9-
$array[array()] = 123;
8+
// Warning
9+
trigger_error("Test warning", E_USER_WARNING);
1010

1111
// Exception
1212
throw new Exception('this is an exception');

0 commit comments

Comments
 (0)