xdebug 3+ php-fpm+ phpstorm步进不起作用

发布于 2025-02-02 18:41:57 字数 3889 浏览 3 评论 0原文

我试图使用php8.0的图像:fpm和nginx配置xdebug 3,但phpstorm不会停止断点。

在日志中,它似乎是连接的,但并没有停止。

[8] Log opened at 2022-05-29 23:54:51.960541
[8] [Step Debug] INFO: Connecting to configured address/port: host.docker.internal:9003.
[8] [Step Debug] INFO: Connected to debugging client: host.docker.internal:9003 (through xdebug.client_host/xdebug.client_port). :-)
[8] [Step Debug] -> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file:///app/public/index.php" language="PHP" xdebug:language_version="8.0.19" protocol_version="1.0" appid="8"><engine version="3.1.4"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[https://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2022 by Derick Rethans]]></copyright></init>

[8] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" status="stopping" reason="ok"></response>

[8] Log closed at 2022-05-29 23:54:52.382689

加载了扩展名:

功能&nbsp; enabled/disabled&nbsp;
&nbsp;开发助手✘残疾&nbsp;
覆盖范围✘禁用
GC统计✘禁用
&nbsp; Profiler✘禁用
步骤调试器✔启用&nbsp;
tracing&nbsp;✘禁用

我的xdebug配置文件是:

zend_extension=xdebug

[xdebug]
xdebug.mode=debug
xdebug.client_host=host.docker.internal
xdebug.client_port=9003
xdebug.start_with_request=yes
xdebug.log="var/log/xdebug.log"
xdebug.start_upon_error=yes

我的dockerfile用于php-fpm:

FROM php:8.0-fpm

RUN apt-get update && apt-get install -y \
    && docker-php-ext-install pdo pdo_mysql

RUN pecl install xdebug

COPY conf.d/xdebug.ini /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini

RUN echo clear_env = no >> /usr/local/etc/php-fpm.d/www.conf

xdebug_mode变量可读取。

我将服务器名称添加为fastcgi param

fastcgi_param SERVER_NAME $server_name;

docker-compose

version: '3.7'
services:
  # APP 
  php:
    build:
      context: .docker/php
    depends_on:
      - mysql
    links:
      - mysql
    volumes:
      - ./:/app
    working_dir: /app
    networks:
      - default
    extra_hosts:
      - host.docker.internal:host-gateway
    environment:
      XDEBUG_MODE: debug

  # NGINX SERVER
  nginx-user-service:
    build:
      context: .docker/nginx
    hostname: com.user-service
    ports:
      - 8010:80
    environment:
      PHP_FPM_HOST: php
    volumes:
      - ./:/app
    restart: always
    depends_on:
      - php
    networks:
      - default
      - cp-network
  
  # APP DATABASE
  mysql:
      image: mysql:8.0
      container_name: ${APP_NAME}-mysql
      environment:
        MYSQL_ROOT_PASSWORD: ${DATABASE_ROOT_PASSWORD}
        MYSQL_DATABASE: ${DATABASE_NAME}
        MYSQL_USER: ${DATABASE_USERNAME}
        MYSQL_PASSWORD: ${DATABASE_PASSWORD}
      networks:
        - default
      ports:
        - 33065:3306
      expose:
        - 33065
networks:
  cp-network:
    external: 
      name: cp-network
  default: 
    name: user-services
    driver: bridge

I'm trying to configure Xdebug 3 using an image of PHP8.0:FPM and Nginx but PhpStorm does not stop on breakpoints.

In the logs it seems to connect, but does not stop.

[8] Log opened at 2022-05-29 23:54:51.960541
[8] [Step Debug] INFO: Connecting to configured address/port: host.docker.internal:9003.
[8] [Step Debug] INFO: Connected to debugging client: host.docker.internal:9003 (through xdebug.client_host/xdebug.client_port). :-)
[8] [Step Debug] -> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file:///app/public/index.php" language="PHP" xdebug:language_version="8.0.19" protocol_version="1.0" appid="8"><engine version="3.1.4"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[https://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2022 by Derick Rethans]]></copyright></init>

[8] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" status="stopping" reason="ok"></response>

[8] Log closed at 2022-05-29 23:54:52.382689

The extension is loaded:

Feature Enabled/Disabled 
 Development Helpers✘ disabled 
Coverage✘ disabled
GC Stats✘ disabled
 Profiler✘ disabled
Step Debugger✔ enabled 
Tracing ✘ disabled

My Xdebug config files is:

zend_extension=xdebug

[xdebug]
xdebug.mode=debug
xdebug.client_host=host.docker.internal
xdebug.client_port=9003
xdebug.start_with_request=yes
xdebug.log="var/log/xdebug.log"
xdebug.start_upon_error=yes

My Dockerfile for php-fpm :

FROM php:8.0-fpm

RUN apt-get update && apt-get install -y \
    && docker-php-ext-install pdo pdo_mysql

RUN pecl install xdebug

COPY conf.d/xdebug.ini /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini

RUN echo clear_env = no >> /usr/local/etc/php-fpm.d/www.conf

The XDEBUG_MODE variable is readable.

I add the server name as fastcgi param

fastcgi_param SERVER_NAME $server_name;

docker-compose

version: '3.7'
services:
  # APP 
  php:
    build:
      context: .docker/php
    depends_on:
      - mysql
    links:
      - mysql
    volumes:
      - ./:/app
    working_dir: /app
    networks:
      - default
    extra_hosts:
      - host.docker.internal:host-gateway
    environment:
      XDEBUG_MODE: debug

  # NGINX SERVER
  nginx-user-service:
    build:
      context: .docker/nginx
    hostname: com.user-service
    ports:
      - 8010:80
    environment:
      PHP_FPM_HOST: php
    volumes:
      - ./:/app
    restart: always
    depends_on:
      - php
    networks:
      - default
      - cp-network
  
  # APP DATABASE
  mysql:
      image: mysql:8.0
      container_name: ${APP_NAME}-mysql
      environment:
        MYSQL_ROOT_PASSWORD: ${DATABASE_ROOT_PASSWORD}
        MYSQL_DATABASE: ${DATABASE_NAME}
        MYSQL_USER: ${DATABASE_USERNAME}
        MYSQL_PASSWORD: ${DATABASE_PASSWORD}
      networks:
        - default
      ports:
        - 33065:3306
      expose:
        - 33065
networks:
  cp-network:
    external: 
      name: cp-network
  default: 
    name: user-services
    driver: bridge

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文