Docker PHPStorm xDebug

Posted 1 year ago by kickthemooon

I hope this is not too off-topic but I am trying to get xdebug working with my laravel docker local environment and I am not having much luck.

This is docker-compose.yml:

version: "2.1"

services:

    nginx:
        image: nginx:latest
        ports:
            - 80:80
        volumes:
            - "./public:/var/www/html/public:ro"
            - "./default.conf:/etc/nginx/conf.d/default.conf"
        depends_on:
            - php

    php:
        image: kickthemooon/php-laravel
        expose:
            - 9000
        volumes:
            - ".:/var/www/html"
            - "./xdebug.ini:/usr/local/etc/php/conf.d/xdebug.ini"
        depends_on:
            - mysql

    mysql:
        image: mysql:latest
        ports:
            - 3306:3306
        volumes:
            - data:/var/lib/mysql
        environment:
            MYSQL_ROOT_PASSWORD: "${DB_PASSWORD}"
            MYSQL_DATABASE: "${DB_DATABASE}"
            MYSQL_USER: "${DB_USERNAME}"
            MYSQL_PASSWORD: "${DB_PASSWORD}"

volumes:
    data:

This is my dockerfile:

FROM php:7.1-fpm

RUN apt-get update && apt-get install -y \
    && docker-php-ext-install pdo_mysql \
    && rm -rf /var/lib/apt/lists/*

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

This is my xdebug.ini:

zend_extension = "/usr/local/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so"
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_connect_back = 1
xdebug.remote_port = 9001

My PHPStorm settings:

phpstorm_debug_configuration

phpstorm_remote_debug_configuration

dbgp_configuration

phpstorm_php_servers_configuration

So that's about it.

I would appreciate any hints and tips. Thanks.

Please sign in or create an account to participate in this conversation.