Add to the Dockerfile:
RUN echo "xdebug.client_port=9000" > /usr/local/etc/php/conf.d/xdebug.ini && \
echo "xdebug.idekey=PHPStorm" >> /usr/local/etc/php/conf.d/xdebug.ini && \
echo "xdebug.mode=debug" >> /usr/local/etc/php/conf.d/xdebug.ini && \
echo "xdebug.remote_enable=1" >> /usr/local/etc/php/conf.d/xdebug.ini && \
echo "xdebug.client_host=172.26.0.3" >> /usr/local/etc/php/conf.d/xdebug.ini
Example docker-compose.yml:
version: '2.4'
services:
app:
container_name: excavo.telegram.app
build: .
ports:
- "80:80"
environment:
PHP_ENABLE_XDEBUG: 1
volumes:
- .:/app
- /app/vendor/
db:
container_name: excavo.telegram.db
image: mysql:5.7.29
restart: always
command: mysqld --sql_mode=""
environment:
MYSQL_DATABASE: excavo.telegram
MYSQL_USER: excavo.telegram
MYSQL_PASSWORD: p^DK@6*7UoiF
MYSQL_RANDOM_ROOT_PASSWORD: 1
volumes:
- excavo.telegram:/var/lib/mysql
volumes:
excavo.telegram:
name: excavo.telegram
Set xdebug.client_host to an address your IDE can reach (often the Docker host gateway IP, not a hard-coded container IP).
IDE path mapping
Map project paths in your IDE so breakpoints resolve correctly.
- Map
/controllersand other app directories explicitly. - If files under
vendor/are missing, check include paths in the IDE mapping dialog. - Prefer mapping whole directories instead of individual files.
Related topics
- WordPress image — Xdebug in a WordPress Dockerfile
- PHP image — PHP extension setup
Andrew Dorokhov