Skip to content

Commit 335e8ca

Browse files
authored
Add --xdebug option in php-wasm CLI and wp-playground CLI (#2346)
1 parent f357bb1 commit 335e8ca

38 files changed

+6691
-4484
lines changed

CHANGELOG.md

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,44 +4,42 @@ All notable changes to this project are documented in this file by a CI job
44
that runs on every NPM release. The file follows the [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
55
format.
66

7-
## [v1.2.2] (2025-07-14)
7+
## [v1.2.2] (2025-07-14)
88

99
### Enhancements
1010

11-
- Add --internal-cookie-store option for Playground CLI. ([#2323](https://github.com/WordPress/wordpress-playground/pull/2323))
11+
- Add --internal-cookie-store option for Playground CLI. ([#2323](https://github.com/WordPress/wordpress-playground/pull/2323))
1212

1313
### Tools
1414

15-
1615
#### PHP WebAssembly
1716

18-
- [ php-wasm ] Add `xdebug` shared extension to @php-wasm/node ASYNCIFY. ([#2326](https://github.com/WordPress/wordpress-playground/pull/2326))
17+
- [ php-wasm ] Add `xdebug` shared extension to @php-wasm/node ASYNCIFY. ([#2326](https://github.com/WordPress/wordpress-playground/pull/2326))
1918

2019
### Documentation
2120

22-
- Add Japanese translations to Using Blueprints. ([#2330](https://github.com/WordPress/wordpress-playground/pull/2330))
23-
- Add Japanese translations to Blueprint data Format. ([#2340](https://github.com/WordPress/wordpress-playground/pull/2340))
24-
- Adding new videos about WordPress Playground. ([#2348](https://github.com/WordPress/wordpress-playground/pull/2348))
25-
- Translate How to contribute pages to Brazilian Portuguese. ([#2329](https://github.com/WordPress/wordpress-playground/pull/2329))
26-
- Updating Translation Guide. ([#2342](https://github.com/WordPress/wordpress-playground/pull/2342))
27-
- Updating slack channel from #meta-playground to #playground. ([#2345](https://github.com/WordPress/wordpress-playground/pull/2345))
21+
- Add Japanese translations to Using Blueprints. ([#2330](https://github.com/WordPress/wordpress-playground/pull/2330))
22+
- Add Japanese translations to Blueprint data Format. ([#2340](https://github.com/WordPress/wordpress-playground/pull/2340))
23+
- Adding new videos about WordPress Playground. ([#2348](https://github.com/WordPress/wordpress-playground/pull/2348))
24+
- Translate How to contribute pages to Brazilian Portuguese. ([#2329](https://github.com/WordPress/wordpress-playground/pull/2329))
25+
- Updating Translation Guide. ([#2342](https://github.com/WordPress/wordpress-playground/pull/2342))
26+
- Updating slack channel from #meta-playground to #playground. ([#2345](https://github.com/WordPress/wordpress-playground/pull/2345))
2827

2928
### PHP WebAssembly
3029

31-
- Support multiple workers for NODEFS /wordpress mounts – Asyncify. ([#2317](https://github.com/WordPress/wordpress-playground/pull/2317))
32-
- [PHP] Support non-blocking read streams. ([#2339](https://github.com/WordPress/wordpress-playground/pull/2339))
30+
- Support multiple workers for NODEFS /wordpress mounts – Asyncify. ([#2317](https://github.com/WordPress/wordpress-playground/pull/2317))
31+
- [PHP] Support non-blocking read streams. ([#2339](https://github.com/WordPress/wordpress-playground/pull/2339))
3332

3433
### Bug Fixes
3534

36-
- Fix: Set an explicit path for docsaurus.config.js. ([#2335](https://github.com/WordPress/wordpress-playground/pull/2335))
35+
- Fix: Set an explicit path for docsaurus.config.js. ([#2335](https://github.com/WordPress/wordpress-playground/pull/2335))
3736

3837
### Contributors
3938

4039
The following contributors merged PRs in this release:
4140

4241
@adamziel @brandonpayton @fellyph @mho22 @rollybueno @shimotmk
4342

44-
4543
## [v1.0.38] (2025-05-22)
4644

4745
### Various

packages/docs/site/docs/main/changelog.md

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,44 +9,42 @@ All notable changes to this project are documented in this file by a CI job
99
that runs on every NPM release. The file follows the [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
1010
format.
1111

12-
## [v1.2.2] (2025-07-14)
12+
## [v1.2.2] (2025-07-14)
1313

1414
### Enhancements
1515

16-
- Add --internal-cookie-store option for Playground CLI. ([#2323](https://github.com/WordPress/wordpress-playground/pull/2323))
16+
- Add --internal-cookie-store option for Playground CLI. ([#2323](https://github.com/WordPress/wordpress-playground/pull/2323))
1717

1818
### Tools
1919

20-
2120
#### PHP WebAssembly
2221

23-
- [ php-wasm ] Add `xdebug` shared extension to @php-wasm/node ASYNCIFY. ([#2326](https://github.com/WordPress/wordpress-playground/pull/2326))
22+
- [ php-wasm ] Add `xdebug` shared extension to @php-wasm/node ASYNCIFY. ([#2326](https://github.com/WordPress/wordpress-playground/pull/2326))
2423

2524
### Documentation
2625

27-
- Add Japanese translations to Using Blueprints. ([#2330](https://github.com/WordPress/wordpress-playground/pull/2330))
28-
- Add Japanese translations to Blueprint data Format. ([#2340](https://github.com/WordPress/wordpress-playground/pull/2340))
29-
- Adding new videos about WordPress Playground. ([#2348](https://github.com/WordPress/wordpress-playground/pull/2348))
30-
- Translate How to contribute pages to Brazilian Portuguese. ([#2329](https://github.com/WordPress/wordpress-playground/pull/2329))
31-
- Updating Translation Guide. ([#2342](https://github.com/WordPress/wordpress-playground/pull/2342))
32-
- Updating slack channel from #meta-playground to #playground. ([#2345](https://github.com/WordPress/wordpress-playground/pull/2345))
26+
- Add Japanese translations to Using Blueprints. ([#2330](https://github.com/WordPress/wordpress-playground/pull/2330))
27+
- Add Japanese translations to Blueprint data Format. ([#2340](https://github.com/WordPress/wordpress-playground/pull/2340))
28+
- Adding new videos about WordPress Playground. ([#2348](https://github.com/WordPress/wordpress-playground/pull/2348))
29+
- Translate How to contribute pages to Brazilian Portuguese. ([#2329](https://github.com/WordPress/wordpress-playground/pull/2329))
30+
- Updating Translation Guide. ([#2342](https://github.com/WordPress/wordpress-playground/pull/2342))
31+
- Updating slack channel from #meta-playground to #playground. ([#2345](https://github.com/WordPress/wordpress-playground/pull/2345))
3332

3433
### PHP WebAssembly
3534

36-
- Support multiple workers for NODEFS /wordpress mounts – Asyncify. ([#2317](https://github.com/WordPress/wordpress-playground/pull/2317))
37-
- [PHP] Support non-blocking read streams. ([#2339](https://github.com/WordPress/wordpress-playground/pull/2339))
35+
- Support multiple workers for NODEFS /wordpress mounts – Asyncify. ([#2317](https://github.com/WordPress/wordpress-playground/pull/2317))
36+
- [PHP] Support non-blocking read streams. ([#2339](https://github.com/WordPress/wordpress-playground/pull/2339))
3837

3938
### Bug Fixes
4039

41-
- Fix: Set an explicit path for docsaurus.config.js. ([#2335](https://github.com/WordPress/wordpress-playground/pull/2335))
40+
- Fix: Set an explicit path for docsaurus.config.js. ([#2335](https://github.com/WordPress/wordpress-playground/pull/2335))
4241

4342
### Contributors
4443

4544
The following contributors merged PRs in this release:
4645

4746
@adamziel @brandonpayton @fellyph @mho22 @rollybueno @shimotmk
4847

49-
5048
## [v1.0.38] (2025-05-22)
5149

5250
### Various

packages/php-wasm/cli/src/main.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ async function run() {
3838
throw new Error(`Unsupported PHP version ${phpVersion}`);
3939
}
4040

41+
const hasXdebugOption = args.some((arg) => arg.startsWith('--xdebug'));
42+
if (hasXdebugOption) {
43+
args = args.filter((arg) => arg !== '--xdebug');
44+
}
45+
4146
// npm scripts set the TMPDIR env variable
4247
// PHP accepts a TMPDIR env variable and expects it to
4348
// be a writable directory within the PHP filesystem.
@@ -86,6 +91,7 @@ ${process.argv[0]} ${process.execArgv.join(' ')} ${process.argv[1]}
8691
PATH: `${tempDir}:${envVariables['PATH']}`,
8792
},
8893
},
94+
withXdebug: hasXdebugOption,
8995
})
9096
);
9197

packages/php-wasm/cli/vite.config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export default defineConfig({
2727
'util',
2828
'dns',
2929
'ws',
30+
'os',
3031
],
3132
input: 'packages/php-wasm/cli/src/main.ts',
3233
output: {
@@ -45,4 +46,8 @@ export default defineConfig({
4546
include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
4647
reporters: ['default'],
4748
},
49+
50+
define: {
51+
'process.env': 'process.env',
52+
},
4853
});

packages/php-wasm/compile/php/Dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,7 @@ RUN export ASYNCIFY_IMPORTS=$'[\n\
745745
"Curl_is_connected",\
746746
"curl_multi_perform",\
747747
"curl_multi_poll",\
748+
"curl_multi_wait",\
748749
"Curl_multi_wait",\
749750
"Curl_ossl_connect_nonblocking",\
750751
"Curl_ossl_seed",\
@@ -966,6 +967,7 @@ RUN export ASYNCIFY_IMPORTS=$'[\n\
966967
"wasm_php_exec",\
967968
"wasm_sapi_handle_request",\
968969
"wasm_sapi_request_shutdown",\
970+
"execute_internal",\
969971
"_call_user_function_ex",\
970972
"_call_user_function_impl",\
971973
"_mysqlnd_run_command",\
@@ -1627,6 +1629,7 @@ RUN export ASYNCIFY_IMPORTS=$'[\n\
16271629
"ZEND_DO_ICALL_SPEC_HANDLER",\
16281630
"ZEND_DO_ICALL_SPEC_RETVAL_UNUSED_HANDLER",\
16291631
"ZEND_DO_ICALL_SPEC_RETVAL_USED_HANDLER",\
1632+
"ZEND_DO_ICALL_SPEC_OBSERVER_HANDLER",\
16301633
"ZEND_DO_UCALL_SPEC_OBSERVER_HANDLER",\
16311634
"zend_emit_op_tmp",\
16321635
"zend_emit_op",\
@@ -1682,6 +1685,7 @@ RUN export ASYNCIFY_IMPORTS=$'[\n\
16821685
"zend_hash_graceful_reverse_destroy",\
16831686
"zend_hash_reverse_apply",\
16841687
"ZEND_INCLUDE_OR_EVAL_SPEC_CV_HANDLER",\
1688+
"ZEND_INCLUDE_OR_EVAL_SPEC_OBSERVER_HANDLER",\
16851689
"zend_include_or_eval",\
16861690
"compile_filename",\
16871691
"zend_internal_type_error",\
@@ -1824,6 +1828,9 @@ RUN export ASYNCIFY_IMPORTS=$'[\n\
18241828
"zend_use_undef_in_read_context_helper_SPEC",\
18251829
"zend_user_it_get_current_data",\
18261830
"zend_user_it_get_new_iterator",\
1831+
"ZEND_USER_OPCODE_SPEC_HANDLER",\
1832+
"ZEND_INCLUDE_OR_EVAL_SPEC_CONST_HANDLER",\
1833+
"ZEND_INCLUDE_OR_EVAL_SPEC_TMPVAR_HANDLER",\
18271834
"zend_value_error",\
18281835
"zend_verify_ref_array_assignable",\
18291836
"zend_vm_stack_extend",\

packages/php-wasm/compile/xdebug/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,9 @@ RUN set -euxo pipefail; \
130130
if [ "$WITH_JSPI" = "yes" ]; then \
131131
export EMCC_FLAGS="${EMCC_FLAGS} -sJSPI -sJSPI_IMPORTS=wasm_recv -sJSPI_EXPORTS=wasm_recv"; \
132132
else \
133-
export EMCC_FLAGS="${EMCC_FLAGS} -sASYNCIFY -sASYNCIFY_ADVISE -sASYNCIFY_IMPORTS=wasm_recv -sASYNCIFY_EXPORTS=wasm_recv"; \
133+
# execute_internal must be in ASYNCIFY_IMPORTS for Xdebug to trace internal PHP functions.
134+
# This enables async unwinding during breakpoints or stepping inside internal calls.
135+
export EMCC_FLAGS="${EMCC_FLAGS} -sASYNCIFY -sASYNCIFY_ADVISE -sASYNCIFY_IMPORTS=wasm_recv,execute_internal -sASYNCIFY_EXPORTS=wasm_recv"; \
134136
fi; \
135137

136138
emmake make -j1

0 commit comments

Comments
 (0)