php - 无法在 Nginx 上使用 Laravel 在 PhpStorm 中触发 Xdebug 中断

标签 php ubuntu nginx phpstorm xdebug

我一直试图让 Xdebug 与在 nginx 上的 php8.0-fpm 上运行的 Laravel 一起工作,但没有成功。
我正在使用 PhpStorm 触发断点,但似乎即使 xdebug_break()不触发。
这些都是我的配置,我也可以发phpinfo()如果需要,在评论中:
nginx:

server {
    listen 80;
    server_name dashboard.local;
    root /var/www/dashboard/public;

    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options "nosniff";

    index index.php;

    charset utf-8;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    error_page 404 /index.php;

    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php/php8.0-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        include fastcgi_params;
    }

    location ~ /\.(?!well-known).* {
        deny all;
    }
}
php 配置:
PHP 8.0.0 (cli) (built: Nov 27 2020 12:26:22) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.0-dev, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.0, Copyright (c), by Zend Technologies
    with Xdebug v3.0.0, Copyright (c) 2002-2020, by Derick Rethans
➜  ~ php-config -v
Usage: /usr/bin/php-config [OPTION]
Options:
  --prefix            [/usr]
  --includes          [-I/usr/include/php/20200930 -I/usr/include/php/20200930/main -I/usr/include/php/20200930/TSRM -I/usr/include/php/20200930/Zend -I/usr/include/php/20200930/ext -I/usr/include/php/20200930/ext/date/lib ]
  --ldflags           [-L/usr/lib/php/20200930 ]
  --libs              [-lcrypt   -largon2 -lresolv -lcrypt -lutil -lrt -lm -ldl  -lxml2 -lssl -lcrypto -lpcre2-8 -lz -lsodium -largon2 -lcrypt ]
  --extension-dir     [/usr/lib/php/20200930]
  --include-dir       [/usr/include/php/20200930]
  --man-dir           [/usr/share/man]
  --php-binary        [/usr/bin/php8.0]
  --php-sapis         [cli fpm ]
  --phpapi            [20200930]
  --ini-path          [/etc/php/8.0/cli]
  --ini-dir           [/etc/php/8.0/cli/conf.d]
  --configure-options [--includedir=/usr/include --mandir=/usr/share/man --infodir=/usr/share/info --disable-silent-rules --libdir=/usr/lib/x86_64-linux-gnu --libexecdir=/usr/lib/x86_64-linux-gnu --disable-maintainer-mode --disable-dependency-tracking --prefix=/usr --enable-cli --disable-cgi --disable-phpdbg --with-config-file-path=/etc/php/8.0/cli --with-config-file-scan-dir=/etc/php/8.0/cli/conf.d --build=x86_64-linux-gnu --host=x86_64-linux-gnu --config-cache --cache-file=/build/php8.0-xu5Vr1/php8.0-8.0.0/config.cache --libdir=${prefix}/lib/php --libexecdir=${prefix}/lib/php --datadir=${prefix}/share/php/8.0 --program-suffix=8.0 --sysconfdir=/etc --localstatedir=/var --mandir=/usr/share/man --disable-all --disable-debug --disable-rpath --disable-static --with-pic --with-layout=GNU --without-pear --enable-filter --with-openssl --with-password-argon2=/usr --with-external-pcre --enable-hash --with-mhash=/usr --with-libxml --enable-session --with-sodium --with-system-tzdata --with-zlib=/usr --with-zlib-dir=/usr --enable-dtrace --enable-pcntl --with-libedit=shared,/usr build_alias=x86_64-linux-gnu host_alias=x86_64-linux-gnu CFLAGS=-g -O2 -fdebug-prefix-map=/build/php8.0-xu5Vr1/php8.0-8.0.0=. -fstack-protector-strong -Wformat -Werror=format-security -O2 -Wall -pedantic -fsigned-char -fno-strict-aliasing -g]
  --version           [8.0.0]
  --vernum            [80000]
xdebug.ini (/etc/php/8.0/mods-available/xdebug.ini):
zend_extension = /usr/lib/php/20200930/xdebug.so
; zend_extension = xdebug.so
xdebug.remote_enable = 1
xdebug.remote_mode = req
xdebug.remote_host = http//dashboard.local
xdebug.remote_port = 9009
xdebug.remoce_connect_back = on
xdebug.remote_handler = "dbgp"
xdebug.remote_autostart = 0
xdebug.idekey = PHPSTORM
xdebug.remote_autostart = 0
xdebug.remote_log = "/var/log/xdebug/xdebug.log"
xdebug.show_error_trace = 1
xdebug.start_with_request = yes
PhpStorm:
PHPStorm config 8.0
Localhost Validation 8.0
谢谢 :)
编辑1:
我已经降级到 php 7.4 和 Xdebug 2.9.8,但似乎我仍然无法从 Xdebug 得到任何响应。根据 LazyOne已要求,这是我拥有的所有配置。
php配置:
Usage: /usr/bin/php-config [OPTION]
Options:
  --prefix            [/usr]
  --includes          [-I/usr/include/php/20190902 -I/usr/include/php/20190902/main -I/usr/include/php/20190902/TSRM -I/usr/include/php/20190902/Zend -I/usr/include/php/20190902/ext -I/usr/include/php/20190902/ext/date/lib ]
  --ldflags           [-L/usr/lib/php/20190902 ]
  --libs              [-lcrypt   -largon2 -lresolv -lcrypt -lrt -lm -ldl  -lxml2 -lssl -lcrypto -lpcre2-8 -lz -lsodium -lcrypt -largon2 -lcrypt ]
  --extension-dir     [/usr/lib/php/20190902]
  --include-dir       [/usr/include/php/20190902]
  --man-dir           [/usr/share/man]
  --php-binary        [/usr/bin/php7.4]
  --php-sapis         [apache2handler cgi cli fpm ]
  --phpapi            [20190902]
  --ini-path          [/etc/php/7.4/cli]
  --ini-dir           [/etc/php/7.4/cli/conf.d]
  --configure-options [--includedir=/usr/include --mandir=/usr/share/man --infodir=/usr/share/info --disable-silent-rules --libdir=/usr/lib/x86_64-linux-gnu --libexecdir=/usr/lib/x86_64-linux-gnu --disable-maintainer-mode --disable-dependency-tracking --prefix=/usr --enable-cli --disable-cgi --disable-phpdbg --with-config-file-path=/etc/php/7.4/cli --with-config-file-scan-dir=/etc/php/7.4/cli/conf.d --build=x86_64-linux-gnu --host=x86_64-linux-gnu --config-cache --cache-file=/build/php7.4-efh2kh/php7.4-7.4.13/config.cache --libdir=${prefix}/lib/php --libexecdir=${prefix}/lib/php --datadir=${prefix}/share/php/7.4 --program-suffix=7.4 --sysconfdir=/etc --localstatedir=/var --mandir=/usr/share/man --disable-all --disable-debug --disable-rpath --disable-static --with-pic --with-layout=GNU --without-pear --enable-filter --with-openssl --with-password-argon2=/usr --with-external-pcre --enable-hash --with-mhash=/usr --with-libxml --enable-session --with-sodium --with-system-tzdata --with-zlib=/usr --with-zlib-dir=/usr --enable-dtrace --enable-pcntl --with-libedit=shared,/usr build_alias=x86_64-linux-gnu host_alias=x86_64-linux-gnu CFLAGS=-g -O2 -fdebug-prefix-map=/build/php7.4-efh2kh/php7.4-7.4.13=. -fstack-protector-strong -Wformat -Werror=format-security -O2 -Wall -pedantic -fsigned-char -fno-strict-aliasing -g]
  --version           [7.4.13]
  --vernum            [70413]

来自 phpinfo() 的 xdebug 部分:
Xdebug 2.9.8 info
Xdebug 2.9.8 info part 2
xdebug 日志:
空的
PHPStorm 配置:
PHPStorm interpreter config php 7.4
Localhost Validation 7.4

最佳答案

在与 LazyOne 的 session 之后我们认为我没有为 Xdebug 使用正确的模式,因为我需要将其设置为 debug .以前我将它设置为 develop这意味着 Development Aids,认为它也包含 Step Debugger。
这就是最终配置的结果(对于 Xdebug 3.0.1):

zend_extension=xdebug.so
xdebug.mode=develop,debug
xdebug.client_port=9009
xdebug.client_host=127.0.0.1
这使我能够触发断点,前提是我在 chrome 中有 Xdebug Helper 扩展,或者在发出请求时提供了 XDEBUG_SESSION_START 参数(在我的情况下 = PHPSTORM)。
再次感谢您的帮助,LazyOne !

关于php - 无法在 Nginx 上使用 Laravel 在 PhpStorm 中触发 Xdebug 中断,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65111800/

相关文章:

php - 使用 VestaCP 在 Centos 7 上将 Payeezy FirstData 自签名证书添加到服务器 Trusted Store CA

php - 如何循环遍历 PDO 语句并在 if 语句上写入数据

php - Facebook 代币用于洞察数据的永久解决方案?

python - Ubuntu 16.10 : Need help installing python3-bsddb3

ruby - Rspec 套件无法在 ECONNREFUSED 的 AWS Ubuntu 上运行 - 但每个测试都单独通过

javascript - NodeJS 从本地主机到在线站点

php - Retrieve data from sql database and display in tables - 根据选中的复选框显示某些数据

php - 使用 PHPUnit 达到 100% 的代码覆盖率

linux - QEMU 简单后端跟踪不打印任何内容

ruby-on-rails - 瘦服务器上的 502 网关错误,为什么?