Skip to main content

xDebug & PhpStorm (Docker)

This guide helps you set up xDebug inside a Docker container with PhpStorm for local debugging.

⚠️ Note: If you're using the default Docker setup from make up, xDebug is already installed and configured.

⚙️ xDebug PHP Configuration

Ensure xdebug is installed in your Docker image. Inside Dockerfile:

RUN pecl install xdebug && docker-php-ext-enable xdebug

In your php.ini (or custom config loaded in Docker):

zend_extension=xdebug.so
xdebug.mode=debug
xdebug.start_with_request=yes
xdebug.client_host=host.docker.internal
xdebug.client_port=9003

🔧 Port 9003 is the default PhpStorm debugger port.

🐳 docker-compose.yml

Ensure the following settings are present:

services:
app:
environment:
PHP_IDE_CONFIG: "serverName=app"
XDEBUG_MODE: "debug"
XDEBUG_CONFIG: "client_host=host.docker.internal"
volumes:
- ./:/var/www/html

🧐 PhpStorm Configuration

  1. Preferences → PHP → Servers

    • Name: stage
    • Host: localhost
    • Port: 8080 (or 80, depending on your RR/HTTP setup)
    • Path Mappings: map /var/www to your local project path
  2. Preferences → PHP → Debug

    • Debug port: 9003
    • Enable: "Start Listening for PHP Debug Connections"
  3. Set a breakpoint and launch your application using make up or ./vendor/bin/rr serve

xDebug config screens

Step 1

Step 2

Step 3

Step 4

Step 5

Step 6

PHP Interpreter config screens

Step 1

Step 2

Step 3

Step 4

Step 5

✅ Testing

Open your app in the browser and trigger a route that hits a breakpoint. PhpStorm should automatically pause execution and open the debugger panel.