PhpStorm+Docker Dev

My Typical Laravel Docker skeleton.

Remote Debug

Dockerfile should install xdebug

Also should enable and config xdebug in php.ini

This is Xdebug 2.x version settings:

This is Xdebug 3.x version settings:

Xdebug 3.x php.ini setting changed a lot compared to 2.x, check official guide:

https://xdebug.org/docs/upgrade_guide

also check stackoverflow post:

https://stackoverflow.com/questions/8049776/xdebug-for-remote-server-not-connecting

zend_extension part is IMPORTANT, do not use other solution.

Nginx Dockerfile config

should expose a correct port EXPOSE 8080

the port should match the docker-compose.yml -> nginx service's ports mapping (the external port)

docker-compose.yml

map local php.ini to docker container

also notice environment:

PHP_IDE_CONFIG's serverName will be used in PHPStorm

PHPStorm Config

  • PHP interpreter

  • Language&Frameworks->PHP->Servers

Lang->PHP->Servers

Name MUST match docker-compose.yml -> php-fpm service -> environment -> PHP_IDE_CONFIG -> serverName

path mapping is important too, make sure local and remote (docker) path mapping is correct. Typically it can be refer to docker-compose.yml -> php-fpm service -> volumes

Final Check

docker-compose up,

set breakpoint, click "Start Listening to PHP Debug Connection", access web application or call api, see if it works.

Last updated

Was this helpful?