PhpStorm中的Xdebug断点不适用于Docker和虚拟主机

时间:2019-07-12 21:59:31

标签: docker docker-compose phpstorm virtualhost xdebug

我尝试使用Docker在PhpStorm中设置调试,并且当我激活“侦听PHP调试连接”时,我的断点不起作用。

我认为,也许是因为我在Docker nginx容器中使用了虚拟主机,而我的基本目录中只有几个项目,而PhpStorm中的映射配置只是

/var/www

这是设置

enter image description here enter image description here enter image description here

我试图将Languages & Frameworks -> PHP -> Servers中的“服务器上的绝对路径”从/var/www更改为/var/www/tdd.test,但是仍然无法正常工作。

这是我的docker-compose文件


    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

我已将以下行添加到php Dockerfile


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

还有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

0 个答案:

没有答案