php - 如何在 Ubuntu 上使用 Valet 进行 php-debug 扩展 - 502 Bad Gateway

标签 php ubuntu nginx visual-studio-code valet

我正在调试一个带有解析错误的简单 index.php:

<?php

echo '<h1> Hello </h1>';

$value = 0;

if($value == 0){
    echo "true";
}else{
    echo "false"
}

我已经在我的 Ubuntu 上配置了 php-debug/Xdebug,设置从不同的论坛读取,但它没有像我希望的那样工作。

它不加载局部变量,而是打开一个 server.php。

Chrome 显示:502 Bad Gateway。

有人遇到过这个错误吗?

安装细节

操作系统 说明:Ubuntu 16.04.4 LTS 发布:16.04 代号:xenial

Xdebug 解析的 phpinfo()

    Xdebug installed: 2.6.1
Server API: Command Line Interface
Windows: no
Zend Server: no
PHP Version: 7.2.9-1
Zend API nr: 320170718
PHP API nr: 20170718
Debug Build: no
Thread Safe Build: no
Configuration File Path: /etc/php/7.2/cli
Configuration File: /etc/php/7.2/cli/php.ini
Extensions directory: /usr/lib/php/20170718

代客版本 2.0.24 当前 Nginx 端口 (HTTP):80 当前 Nginx 端口 (HTTPS):443## 标题 ##

Xdebug.ini

zend_extension=/usr/lib/php/20170718/xdebug.so
xdebug.remote_autostart = 1
xdebug.remote_enable = 1
xdebug.remote_handler = dbgp
xdebug.remote_host = localhost
xdebug.remote_log = /tmp/xdebug_remote.log
xdebug.remote_mode = req
xdebug.remote_port = 9000 #if you want to change the port you can change

启动.JSON

{ "version": "0.2.0", "configurations": [ { "name": "Listen for XDebug", "type": "php", "request": "launch", "port": 9000 }, { "name": "Launch currently open script", "type": "php", "request": "launch", "program": "${file}", "cwd": "${fileDirname}", "port":
9000 } ] }

最佳答案

我使用 Xdebug 和 VScode 为 Valet 发布的这个设置是正确的。它将为您的配置。我对 Xdebug 调试解析错误的期望是不正确的。调试前应删除解析错误。来自 stackoverflow 用户 Amade 的有见地的评论如下:

Okay, in this case, you were doing it right in the beginning, just I think had somehow wrong expectations of xdebug with valet. It will open server.php from valet, since that's where the file with syntax error is required from. I don't think there is anything really you can do about it. But as you're working with VSCode, don't you get notifications of syntax errors in your panel? You can open it with ctrl+j

关于php - 如何在 Ubuntu 上使用 Valet 进行 php-debug 扩展 - 502 Bad Gateway,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51941435/

相关文章:

ssl - nginx - 反向代理证书认证

php - mysql 和 php 安全 : database as catalog only

php - 如何在单列 MySQL 查询中设置所有值

php - 用户创建时的随机 ID 号

php - 如何在 ubuntu 服务器上删除 codeigniter 中的 index.php?

ubuntu - 尝试使用 systemd 在 ubuntu 服务器上运行 apache Airflow

regex - 使用 nginx 重定向所有小于固定值的 id,如何?

java - 从java到php5?

c - 在 Ubuntu 下从串口读取和写入 USB 秤

GKE 上的 nginx-ingress 无法路由到配置服务的路径