Как заставить работать vscode+xdebug+docker?
Подскажите пожалуйста, как заставить работать связку xdebug+docker+vscode? В сети много информации, только с phpshtorm. Есть конечно и какие-то статьи касающиеся vscode(на ru.stackoverflow тоже смотрел), но почему-то настроить не получается. Имеется docker-compose.yml:
version: "3"
services:
#Nginx сервис
nginx:
image: nginx:alpine
container_name: nginx_container
restart: unless-stopped
tty: true
ports:
- ${NGINX_PORT}:80
volumes:
- ${APP_PATH_HOST}:${APP_PATH_CONTAINER}
- ./docker/nginx/conf.d/:/etc/nginx/conf.d
#PHP сервис
php:
build:
context: .
dockerfile: ./docker/php/Php.Dockerfile
container_name: php_container
restart: unless-stopped
tty: true
working_dir: ${APP_PATH_CONTAINER}
volumes:
- ${APP_PATH_HOST}:${APP_PATH_CONTAINER}
- ./docker/php/php.ini:/usr/local/etc/php/conf.d/local.ini
- ./docker/php/xdebug.ini:/usr/local/etc/php/conf.d/xdebug.ini
Файл xdebug.ini:
zend_extension=xdebug.so
xdebug.remote_host=192.168.32.1
xdebug.remote_autostart = 1
xdebug.remote_enable = 1
xdebug.remote_handler = dbgp
xdebug.idekey=VSCODE
xdebug.remote_log=xdebug.log
xdebug.remote_port=9000
xdebug.remote_connect_back=0
Файл dockerfile:
FROM php:7.3-fpm
WORKDIR /var/www/
# Устанавливаем необходимые для расширений пакеты
RUN apt-get update && apt-get install -y zlib1g-dev libicu-dev \
libfreetype6-dev \
libjpeg62-turbo-dev \
libmcrypt-dev \
libmagickwand-dev \
libmagickcore-dev \
libpng-dev \
libxslt1-dev \
libzip-dev \
zip unzip \
--no-install-recommends
# Устанавливаем расширения intl, PDO MySQL, bcmath, xsl, zip, mysqli, soap
RUN pecl channel-update pecl.php.net \
&& docker-php-ext-install intl pdo_mysql bcmath xsl zip mysqli soap \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install gd \
&& docker-php-ext-install pcntl && docker-php-ext-enable pcntl \
&& pecl install xdebug \
&& docker-php-ext-enable xdebug
# Устанавливаем vim и git
RUN apt-get update && apt-get install -y \
build-essential \
vim \
git-core
# Удаляем ненужные пакеты и чистим образ
RUN apt-get purge -y g++ \
&& apt-get autoremove -y \
&& rm -r /var/lib/apt/lists/ \
&& rm -rf /tmp/
# Add user for laravel application
RUN groupadd -g 1000 www
RUN useradd -u 1000 -ms /bin/bash -g www www
# Copy existing application directory permissions
COPY --chown=www:www . /var/www
# Change current user to www
USER www
EXPOSE 9000
CMD ["php-fpm"]
И файл launch.json для самого xdebug:
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9000,
"log": true,
"externalConsole": false,
"pathMappings": {
"/var/www/": "${workSpacefolder}/src/"
}
}
]
}
Если смотреть через phpinfo(), то видно что все настройки из xdebug.ini подвязались и в лог-файле, написано что есть соединение:
[6] Log opened at 2020-08-06 13:22:17
[6] I: Connecting to configured address/port: 192.168.32.1:9000.
[6] I: Connected to client. :-)
[6] -> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file:///var/www/index.php" language="PHP" xdebug:language_version="7.3.20" protocol_version="1.0" appid="6" idekey="VSCODE"><engine version="2.9.6"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[https://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2020 by Derick Rethans]]></copyright></init>
[6] <- breakpoint_list -i 1
[6] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="1"></response>
[6] <- breakpoint_set -i 2 -t line -f file:///media/konstantin/Other/Develop/PHP/Lessons/src/index.php -n 3
[6] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="2" id="60001"></response>
[6] <- breakpoint_set -i 3 -t line -f file:///media/konstantin/Other/Develop/PHP/Lessons/src/index.php -n 5
[6] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="3" id="60002"></response>
[6] <- breakpoint_list -i 4
[6] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="4"><breakpoint type="line" filename="file:///media/konstantin/Other/Develop/PHP/Lessons/src/index.php" lineno="5" state="enabled" hit_count="0" hit_value="0" id="60002"></breakpoint><breakpoint type="line" filename="file:///media/konstantin/Other/Develop/PHP/Lessons/src/index.php" lineno="3" state="enabled" hit_count="0" hit_value="0" id="60001"></breakpoint></response>
[6] <- breakpoint_list -i 5
[6] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="5"><breakpoint type="line" filename="file:///media/konstantin/Other/Develop/PHP/Lessons/src/index.php" lineno="5" state="enabled" hit_count="0" hit_value="0" id="60002"></breakpoint><breakpoint type="line" filename="file:///media/konstantin/Other/Develop/PHP/Lessons/src/index.php" lineno="3" state="enabled" hit_count="0" hit_value="0" id="60001"></breakpoint></response>
[6] <- breakpoint_set -i 6 -t exception -x *
[6] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="6" id="60003"></response>
[6] <- run -i 7
[6] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="run" transaction_id="7" status="stopping" reason="ok"></response>
[6] <- stop -i 8
[6] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="stop" transaction_id="8" status="stopped" reason="ok"></response>
[6] Log closed at 2020-08-06 13:22:17
но на точках останова xdebug не останавливается. IP xdebug.remote_host=192.168.32.1 который отдает nginx, когда билдит сборку. Через консоль в системе он пингуется. Подскажите пожалуйста, чего не так. может уже кто-нибудь себе настроил. Благодарю.