0

Пытаюсь покрестить phpstorm + xdebug + docker. Ендпоинты не срабатывают

введите сюда описание изображения

Настройки:

docker-compose.yml:

version: "3"

services:
  app:
    build: docker/php
    volumes:
      - ./:/app
    depends_on:
      - mailcatcher
    environment:
      XDEBUG_CONFIG: "remote_host=192.168.220.13 remote_enable=1 remote_log=/app/xdebug.log idekey=PHPSTORM"
      PHP_IDE_CONFIG: "serverName=Docker"
    networks:
      internal:
        ipv4_address: 192.168.220.13


  webpacker:
    image: node:9-alpine
    working_dir: /app
    volumes:
      - ./:/app
    command: /bin/true

  nginx:
    image: nginx:alpine
    ports:
      - 80:80
    volumes:
      - ./:/app
      - ./docker/nginx/vhost.conf:/etc/nginx/conf.d/vhost.conf
    depends_on:
      - app
    networks:
      - internal

  redis:
    image: redis:alpine
    restart: always
    ports:
      - "6381:6379"
    networks:
      - internal

  mailcatcher:
    image: schickling/mailcatcher:latest
    ports:
      - 1080:1080
    networks:
      - internal

  db:
    image: mdillon/postgis:10-alpine
    restart: always
    volumes:
      - ./docker/postgres/backups:/var/lib/postgresql/backups
      - ./docker/postgres/init.sh:/app/db/init.sh
    ports:
      - "5433:5432"
    networks:
      - internal
    environment:
      POSTGRES_DATABASE: az_dev
      POSTGRES_USER: az
      POSTGRES_PASSWORD: az#!dev


networks:
  internal:
    driver: bridge
    ipam:
      driver: default
      config:
        - subnet: 192.168.220.0/28

php/Dockerfile

FROM php:7.1-fpm

# Install modules
RUN apt-get update && apt-get install -y \
        libfreetype6-dev \
        libjpeg62-turbo-dev \
        libmcrypt-dev \
        libpng-dev \
        libicu-dev \
        libpq-dev \
        wget \
        git \
        libxml2-dev \
        zbar-tools \
            --no-install-recommends

RUN docker-php-ext-install mcrypt zip intl mbstring pdo_pgsql exif bcmath xmlrpc soap \
    && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
    && docker-php-ext-install gd \
    && CFLAGS="-I/usr/src/php" docker-php-ext-install xmlreader

RUN pecl install xdebug-2.6.1 \
    && docker-php-ext-enable xdebug \
    && rm -rf /tmp/pear

COPY ./install-composer.sh /
COPY ./php.ini /usr/local/etc/php/
COPY ./www.conf /usr/local/etc/php/

RUN apt-get purge -y g++ \
    && apt-get autoremove -y \
    && rm -r /var/lib/apt/lists/* \
    && rm -rf /tmp/* \
    && sh /install-composer.sh \
    && rm /install-composer.sh

RUN usermod -u 1000 www-data

VOLUME /root/.composer
WORKDIR /app

EXPOSE 9000
CMD ["php-fpm"]

vhost.conf

# frontend
server {
    charset utf-8;
    client_max_body_size 128M;

    listen 80 default; ## listen for ipv4
    #listen [::]:80 default_server ipv6only=on; ## listen for ipv6

    gzip on;
    gzip_disable "msie6";

    gzip_comp_level 6;
    gzip_min_length 1100;
    gzip_buffers 16 8k;
    gzip_proxied any;
    gzip_types
        text/plain
        text/css
        text/js
        text/xml
        text/javascript
        application/javascript
        application/x-javascript
        application/json
        application/xml
        application/rss+xml
        image/svg+xml;

    server_name 127.0.0.1 localhost;
    root        /app/frontend/web;
    index       index.php;

    access_log  /var/log/nginx/access.log;
    error_log   /var/log/nginx/error.log;

    location / {
        # Redirect everything that isn't a real file to index.php
        try_files $uri $uri/ /index.php$is_args$args;
    }

    # uncomment to avoid processing of calls to non-existing static files by Yii
    location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {
        gzip_static on;
        try_files $uri =404;
    }
    #error_page 404 /404.html;

    # deny accessing php files for the /assets directory
    location ~ ^/assets/.*\.php$ {
        deny all;
    }

    location ~ \.php$ {
        fastcgi_buffer_size 32k;
        fastcgi_buffers 4 32k;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_pass php-fpm;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_read_timeout 300;
    }

    location ~* /\. {
        deny all;
    }
}
## PHP-FPM Servers ##
upstream php-fpm {
    server app:9000;
}

1 ответ 1

2

В опции xdebug.remote_host=192.168.220.13 должен быть указан доступный из контейнера адрес локальной машины, на которой запущен phpstorm, а не адрес докер-контейнера.

Если всё корректно с сетью, то иногда помогает перезапуск PhpStorm после любых изменений настроек remote-xdebug listener'а.

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.