看起来一切正常,但 VSCode 并没有停止调试。我有一个运行 PHP 映像的 docker 容器。
我需要做什么才能在断点处停下来?
我在日志中看不到错误,恰恰相反,他们似乎在说断点配置得很好,并且代码运行正确。
容器的 IP为 172.22.0.2,我的主机的 IP为 172.22.0.1
文件xdebugo.so存在于容器内: /usr/local/lib/php/extensions/no-debug-non-zts-20190902/xdebug.so
主机host.docker.internal已正确设置。
我使用以下方法构建了我的图像:docker build -t phpdebug:5 .
该文件/usr/local/etc/php/conf.d/xdebug.ini
存在于正在运行的容器中。
启动.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9000,
"log": true,
"externalConsole": false,
"pathMappings": {
"/": "${workspaceRoot}/"
}
}
]
}
码头工人-compose.yml
version: '2'
services:
app:
restart: 'no'
image: phpdebug:5
command: php -S 0.0.0.0:8000
ports:
- "8000:8000"
volumes:
- phpdata:/app
environment:
PHP_EXTENSION_XDEBUG: 1
volumes:
phpdata:
driver: local
driver_opts:
type: 'none'
o: 'bind'
device: '/home/element/php/tuto'
/usr/local/etc/php/conf.d/xdebug.ini
zend_extension="/usr/local/lib/php/extensions/no-debug-non-zts-20190902/xdebug.so"
xdebug.default_enable=1
xdebug.remote_enable=1
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.remote_connect_back=0
xdebug.remote_host=host.docker.internal
xdebug.idekey=VSCODE
xdebug.remote_autostart=1
xdebug.remote_log=/usr/local/etc/php/xdebug.log
/etc/hosts
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.22.0.2 d484e93eed2a
172.22.0.1 host.docker.internal
Dockerfile:
FROM php
RUN pecl install xdebug
RUN ip -4 route list match 0/0 | awk '{print $3 "host.docker.internal"}' >> /etc/hosts
COPY custom.ini /usr/local/etc/php/conf.d/xdebug.ini
长风秋雁