Skip to content

Commit

Permalink
[FrankenPHP] Add Xdebug support (#179)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dunglas authored Dec 3, 2024
1 parent 38a5dfa commit 34b8c25
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Runner.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 34b8c25

Please sign in to comment.