L
L
Lenskiy-e2019-07-13 10:37:12
PHP
Lenskiy-e, 2019-07-13 10:37:12

Why don't breakpoints work in xdebug + phpstorm + docker?

Good day to all! Trying to set up xdebug in phpstorm using docker.
I have nginx on which there are several virtual hosts, below is the docker-compose.yml code, snippet php-fpm Dockerfile and xdebug.ini

version: '3.1'
    
    volumes:
      esdata01:
        driver: local
      esdata02:
        driver: local
    
    networks:
      esnet:
      frontend:
      backend:
      internal:
        driver: bridge
        ipam:
          driver: default
          config:
            - subnet: 192.168.220.0/28
      
    services:
      nginx:
        image: nginx
        ports:
            - "80:80"
            - "443:443"
        volumes:
          - ./hosts:/etc/nginx/conf.d
          - ./www:/var/www
          - ./logs:/var/log/nginx
        links:
          - php
        networks:
          - internal
    
      mysql:
        image: mysql:5.7
        ports:
        - "3306:3306"
        volumes:
          - ./mysql:/var/lib/mysql
        environment:
            MYSQL_ROOT_PASSWORD: secret
        networks:
          - internal
    
      # postgres:
      #   image: postgres
    
      #   ports: 
      #     - "3306:3306"
    
      #   environment:
      #       MYSQL_ROOT_PASSWORD: secret
    
      adminer:
        image: adminer
        restart: always
        ports:
          - 8080:8080
        networks:
          - esnet
    
      php:
        build: ./images/php
    
        links:
          - mysql
    
        volumes:
          - ./www:/var/www
    
        networks:
          - internal
    
        extra_hosts:
          - "dockerhost:10.0.75.1"
    
        environment:
          XDEBUG_CONFIG: "remote_host=dockerhost remote_enable=1 idekey=PHPSTORM"
          PHP_IDE_CONFIG: "serverName=Docker"
    
      workspace:
          build: ./images/workspace
          volumes:
            - ./www:/var/www:cached
          extra_hosts:
            - "dockerhost:10.0.75.1"
          ports:
            - "2222:22"
          tty: true
    
      elasticsearch:
        image: docker.elastic.co/elasticsearch/elasticsearch:7.2.0
        container_name: elasticsearch
        environment:
          - node.name=elasticsearch
          - discovery.seed_hosts=es02
          - cluster.initial_master_nodes=elasticsearch
          - cluster.name=docker-cluster
          - bootstrap.memory_lock=true
          - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
        ulimits:
          memlock:
            soft: -1
            hard: -1
        volumes:
          - esdata01:/usr/share/elasticsearch/data
        ports:
          - 9200:9200
        networks:
          - esnet
      # es02:
      #   image: docker.elastic.co/elasticsearch/elasticsearch:7.2.0
      #   container_name: es02
      #   environment:
      #     - node.name=es02
      #     - discovery.seed_hosts=es01
      #     - cluster.initial_master_nodes=es01,es02
      #     - cluster.name=docker-cluster
      #     - bootstrap.memory_lock=true
      #     - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
      #   ulimits:
      #     memlock:
      #       soft: -1
      #       hard: -1
      #   volumes:
      #     - esdata02:/usr/share/elasticsearch/data
      #   networks:
      #     - esnet
    
      redis:
        image: redis:latest
    
        volumes:
              - ./www/redis:/data
    
        ports:
          - "6379:6379"
        networks:
          - esnet

ADD ./php.ini /usr/local/etc/php/php.ini
    ADD ./xdebug.ini /usr/local/etc/php/xdebug.ini

xdebug.remote_host=dockerhost
    xdebug.remote_connect_back=1
    xdebug.remote_port=9000
    xdebug.idekey=PHPSTORM
    
    xdebug.remote_autostart=0
    xdebug.remote_enable=1
    xdebug.cli_color=0
    xdebug.profiler_enable=0
    xdebug.profiler_output_dir="~/xdebug/phpstorm/tmp/profiling"
    
    xdebug.remote_handler=dbgp
    xdebug.remote_mode=req
    
    xdebug.var_display_max_children=-1
    xdebug.var_display_max_data=-1
    xdebug.var_display_max_depth=-1

I set it up according to the instructions, everything seemed to be fine, the validation passed, but when I set breakpoints and start listening, nothing happens. By the way, I also insisted through laradock - everything worked.
I suspect that this may be due to the fact that in the root directory /var/www in the php-fpm configuration there are several more directories with projects, perhaps a finer setting is needed.
Please help, thanks!
5d298a15ce79a022228490.png
5d298a2002f11966770734.png
5d298a249b81b427150899.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
serginhold, 2019-07-13
@serginhold

xdebug.idekey = "PHPSTORM"
xdebug.default_enable = 1
xdebug.remote_enable = 1
xdebug.remote_host = host.docker.internal

here with the latter it just starts up
https://blog.jetbrains.com/phpstorm/2018/08/quicks...
+ I also have the Xdebug helper extension installed in chrome for convenience (for on/off)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question