For the complete documentation index, see llms.txt. Markdown versions of documentation pages are available by appending .md to page URLs.
Skip to content

Debugging

You can use RoadRunner with the Xdebug extension. To enable it, configure your IDE to accept remote connections.

If you run multiple PHP processes you have to extend the maximum number of allowed connections to the number of active workers, otherwise some calls would not be caught on your breakpoints.

Xdebug for RoadRunner installed on your system

xdebug

To activate Xdebug, set xdebug.mode=debug in your php.ini.

To enable Xdebug in your application, set the environment variable XDEBUG_SESSION:

Please keep in mind this guide: xdebug3.

You should be able to use breakpoints and view state at this point.

PhpStorm notes

Xdebug for RoadRunner in Docker

The application image below uses the official RoadRunner v3 image.

First, create a docker-compose.yml file in your project root, or copy the environment and extra_hosts sections into your existing docker-compose.yml:

Create api/public/ for the static middleware. Put the PHP worker and its Composer dependencies in api/, which is mounted at /app. Create api/.rr.yaml with this configuration:

Next, create a Dockerfile in your project root or copy the following content:

The example uses Xdebug 3.5.3 and runs as the app user.

Next, create an xdebug.ini file in your project root or copy the following content:

Next, change the settings in your IDE so it can accept remote connections. For example, in PhpStorm go to PHP > Debug and set the following options:

PhpStorm xDebug settings

Next, create a Server entry in your IDE. For example, in PhpStorm go to PHP > Servers and set the following options:

PhpStorm xDebug server settings

Also check the Docker settings in your IDE. For example, in PhpStorm go to Build, Execution, Deployment > Docker and set the following options:

PhpStorm Docker settings

Jobs debugging

Prerequisites

  1. Xdebug 3 installed and properly configured.

  2. Number of jobs workers set to 1 with jobs.pool.num_workers configuration option in .rr.yaml.

Debug process

If you have any active Xdebug listener while starting RoadRunner with Xdebug enabled, disable it. This will prevent a false-positive debug session.

Once RoadRunner starts all workers, enable XDebug listener and reset jobs workers with:

Now you should see the debug session started:

  1. Step over to where the job task is being resolved with $consumer->waitTask().

  2. As soon as you reach it, the debugger stops but the session remains active.

  3. Trigger task consumption with either an HTTP request or a console command (depending on how your application works), and continue debugging the job worker within the active session.

  4. You can continue debugging jobs as long as the debug session is active.

If the connection/session is broken or times out, you can repeat the instructions above to reestablish the connection by resetting job workers.

Last updated