From 913d6f3d76c77059787fd1039fe437dcd3c5ee00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Tue, 3 Dec 2024 16:58:18 +0100 Subject: [PATCH] [FrankenPHP] Add Xdebug support --- src/frankenphp-symfony/src/Runner.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/frankenphp-symfony/src/Runner.php b/src/frankenphp-symfony/src/Runner.php index 89bcd49..afb704d 100644 --- a/src/frankenphp-symfony/src/Runner.php +++ b/src/frankenphp-symfony/src/Runner.php @@ -27,10 +27,17 @@ public function run(): int // Prevent worker script termination when a client connection is interrupted ignore_user_abort(true); + $xdebugConnectToClient = function_exists('xdebug_connect_to_client'); + $server = array_filter($_SERVER, static fn (string $key) => !str_starts_with($key, 'HTTP_'), ARRAY_FILTER_USE_KEY); $server['APP_RUNTIME_MODE'] = 'web=1&worker=1'; - $handler = function () use ($server, &$sfRequest, &$sfResponse): void { + $handler = function () use ($server, &$sfRequest, &$sfResponse, $xdebugConnectToClient): void { + // Connect to the Xdebug client if it's available + if ($xdebugConnectToClient) { + xdebug_connect_to_client(); + } + // Merge the environment variables coming from DotEnv with the ones tied to the current request $_SERVER += $server;