Api Platform conference
Register now
v2.4 Debugging
API Platform Conference
September 19-20, 2024 | Lille & online

The international conference on the API Platform Framework

API Platform Conference 2024: meet the best PHP, JavaScript and API experts

Learn more about the event, register for the conference, and get ready for two days of inspiration, ideas, and knowledge-sharing with our incredible lineup of renowned specialists and advocates.

Register now


The default Docker stack is shipped without a Xdebug stage. It’s easy though to add Xdebug to your project, for development purposes such as debugging tests or remote API requests.

Add a Development Stage to the Dockerfile

To avoid deploying API Platform to production with an active Xdebug extension, it’s recommended to add a custom stage to the end of the api/Dockerfile.

# api/Dockerfile
FROM api_platform_php as api_platform_php_dev

RUN set -eux; \
	apk add --no-cache --virtual .build-deps $PHPIZE_DEPS; \
	pecl install xdebug-$XDEBUG_VERSION; \
	docker-php-ext-enable xdebug; \
	apk del .build-deps

Configure Xdebug with Docker Compose Override

Using an override file named docker-compose.override.yml ensures that the production configuration remains untouched.

As an example, an override could look like this:

version: "3.4"

      target: api_platform_php_dev
      # See https://docs.docker.com/docker-for-mac/networking/#i-want-to-connect-from-a-container-to-a-service-on-the-host
      # See https://github.com/docker/for-linux/issues/264
      # The `remote_host` below may optionally be replaced with `remote_connect_back`
      # This should correspond to the server declared in PHPStorm `Preferences | Languages & Frameworks | PHP | Servers`
      # Then PHPStorm will use the corresponding path mappings
      PHP_IDE_CONFIG: serverName=api-platform


Inspect the installation with the following command. The requested Xdebug version should be displayed in the output.

$ docker-compose exec php php --version

    with Xdebug v2.7.2 …

You can also help us improve the documentation of this page.

Made with love by

Les-Tilleuls.coop can help you design and develop your APIs and web projects, and train your teams in API Platform, Symfony, Next.js, Kubernetes and a wide range of other technologies.

Learn more

Copyright © 2023 Kévin Dunglas

Sponsored by Les-Tilleuls.coop