Skip to content

Instantly share code, notes, and snippets.

@jdecode
Created January 2, 2023 21:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jdecode/d0a5c7e89e90340b158e90ab32a6d695 to your computer and use it in GitHub Desktop.
Save jdecode/d0a5c7e89e90340b158e90ab32a6d695 to your computer and use it in GitHub Desktop.
Setup Xdebug in PhpStorm when PHP/Xdebug is in Docker container

In Docker

  1. Install xdebug in docker
  2. discover_client_host to be set to false/0
  3. client_host to be set to docker.host.internal, using extra_hosts as host.docker.internal:host-gateway

In PhpStorm

  1. Start listening
  2. PHP > Debug : Clear Break at first line in PHP scripts, Debug port = 9000,9003 [check Can accept external connections]
  3. PHP > Servers : + : Host/Port of docker, map public/index.php of host and server

"SHOULD" work

Date : January, 2023

Setup :

  1. PhpStorm (latest, as of now)
  2. Xdebug 3.2
  3. PHP 8.1
  4. Laravel 9.x
  5. Postgres 14.x
  6. Apache 2.x
  7. Ubuntu 22.04 LTS [Host OS]
  8. Docker / Docker-compose 20.10 / 1.29
  9. Debian [Docker OS] (stable/LTS as of now)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment