You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[ xdebug ] Bridge DBGP session with CDP server (#2402)
## Motivation for the change, related issues
Populates the new `php-wasm-xdebug-bridge` package which will connect
Xdebug with Browser Devtools.
[Roadmap](#2315)
## Related issues and pull requests
- #2346
- #2398
- #2288
## Implementation details
- DBGP communication TCP server, which the bridge uses to communication
between PHP.wasm XDebug and the CDP server. XDebug defaultly discusses
on port 9003. While the DBGP server is set on port 9003 by default.
- CDP Websocket Server, which communicates between the Browser Devtools
and the DBGP server, with the help of a bridge. The default port is
9229.
- XDebug <-> CDP Bridge, which ties the above implementations together.
It plays with all the specificities of the DBGP protocol and the CDP
protocol.
- A `startBridge` function that will initialize the servers, get the
soon-to-be-debugged files and return the built bridge.
- A CLI tool that will start the bridge between the browser and a
XDebug.
## Testing Instructions
Create a `xdebug.php` PHP file at the root of the repository :
```php
<?php
$test = 42; // Set a breakpoint on this line
echo "Output!\n";
function test() {
echo "Hello Xdebug World!\n";
}
test();
```
### From Wordpress-Playground repository
1. Run the `xdebug-bridge` command in a first terminal :
```
> npx nx run php-wasm-xdebug-bridge:dev
...
Chrome connected! Initializing Xdebug receiver...
XDebug receiver running on port 9003
Running a PHP script with Xdebug enabled...
```
2. Run the `php-wasm-cli` command in a second terminal :
```
> nx run php-wasm-cli:dev --xdebug xdebug.php
Output!
Hello Xdebug World!
```
### From non-related Playground project
1. Install dependencies
```
npm install @php-wasm/cli @php-wasm/xdebug-bridge
```
2. Run the `xdebug-bridge` command in a first terminal :
```
> npx xdebug-bridge
...
Chrome connected! Initializing Xdebug receiver...
XDebug receiver running on port 9003
Running a PHP script with Xdebug enabled...
```
3. Run the `@php-wasm/cli` command in a second terminal :
```
> npx cli --xdebug xdebug.php
Output!
Hello Xdebug World!
```
<img width="748" height="409" alt="screencapture"
src="https://github.com/user-attachments/assets/b0232831-c9b3-4bb2-95aa-b1d51b72766e"
/>
---------
Co-authored-by: mho22 <[email protected]>
0 commit comments