Skip to content

Commit 237c849

Browse files
authored
[FrankenPHP] Add Xdebug support (#179)
Use the new [`xdebug_connect_to_client()`](https://xdebug.org/docs/all_functions#xdebug_connect_to_client) function if available to allow debugging with Xdebug in worker mode.
1 parent 2246529 commit 237c849

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/frankenphp-symfony/src/Runner.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,17 @@ public function run(): int
2727
// Prevent worker script termination when a client connection is interrupted
2828
ignore_user_abort(true);
2929

30+
$xdebugConnectToClient = function_exists('xdebug_connect_to_client');
31+
3032
$server = array_filter($_SERVER, static fn (string $key) => !str_starts_with($key, 'HTTP_'), ARRAY_FILTER_USE_KEY);
3133
$server['APP_RUNTIME_MODE'] = 'web=1&worker=1';
3234

33-
$handler = function () use ($server, &$sfRequest, &$sfResponse): void {
35+
$handler = function () use ($server, &$sfRequest, &$sfResponse, $xdebugConnectToClient): void {
36+
// Connect to the Xdebug client if it's available
37+
if ($xdebugConnectToClient) {
38+
xdebug_connect_to_client();
39+
}
40+
3441
// Merge the environment variables coming from DotEnv with the ones tied to the current request
3542
$_SERVER += $server;
3643

0 commit comments

Comments
 (0)