为什么 Vagrant 和 Xdebug 的组装在最新版本的 PHP 上不起作用? [英] Why does assembly of Vagrant and Xdebug not works on latest versions of PHP?

查看:52
本文介绍了为什么 Vagrant 和 Xdebug 的组装在最新版本的 PHP 上不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 vagrant + nginx + PHP + xdebug 的工作程序集.PHP 版本为 7.0 时一切正常,但是当我将 PHP 升级到 7.2 或 7.4 时,Xdebug 停止工作.Xdebug 安装了最新版本(3.0.1).

I have the working assembly of vagrant + nginx + PHP + xdebug. Everything is ok while the PHP version is 7.0, but when I upgrade PHP to 7.2 or 7.4 Xdebug stop works. Xdebug installed the latest version (3.0.1).

Vagrantfile(部分):

sudo add-apt-repository -y ppa:ondrej/php
sudo add-apt-repository -y ppa:ondrej/nginx
sudo apt-get update

sudo apt-get install -y nginx
sudo apt-get install -y php7.0-fpm php7.0-xdebug

sudo service php7.0-fpm stop
sudo cp /vagrant/.provision/xdebug.ini /etc/php/7.0/mods-available/xdebug.ini
sudo service php7.0-fpm start

sudo service nginx start
sudo cp /vagrant/.provision/project.local /etc/nginx/sites-available/project.local
sudo chmod 644 /etc/nginx/sites-available/project.local
sudo ln -s /etc/nginx/sites-available/project.local /etc/nginx/sites-enabled/project.local
sudo service nginx restart

Nginx 配置:

server {

  listen 80;
  index index.php;
  server_name project.local www.project.local;

  root /var/www/project.local;
  access_log /var/log/nginx/access.log;
  error_log /var/log/nginx/error.log;

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

  location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/run/php/php7.0-fpm.sock;
  }
}

Xdebug 配置:

zend_extension=xdebug.so
xdebug.remote_enable=1
xdebug.remote_autostart=1
xdebug.remote_connect_back=1
xdebug.remote_host=192.168.33.11
xdebug.remote_port=9001
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_cookie_expire_time = 36000
xdebug.remote_log=/var/www/project.local/.xdebug/xdebug.log
xdebug.idekey=vagrant

这些配置适用于 php7.0-fpm,但不适用于 php7.2-fpm 或 php7.4-fpm.问题出在哪里?

These configs working on php7.0-fpm, but not working on php7.2-fpm or php7.4-fpm. Where can be the problem?

推荐答案

Xdebug 安装了最新版本(3.0.1).

Xdebug installed the latest version (3.0.1).

您正在使用 Xdebug v3,但继续使用 Xdebug v2 配置参数.您需要通过 从 Xdebug 2 升级到 3 指南 并调整您的设置(主要只是更改参数名字).

You are using Xdebug v3 but keep using Xdebug v2 config parameters. You need to go through Upgrading from Xdebug 2 to 3 Guide and adjust your settings (mostly just change the parameter names).

Xdebug v3 使用与 Xdebug v2 不同 的配置参数.从我看到的 10 个xdebug"中有 9 个.您当前 php.ini 中的参数在 Xdebug v3 中什么都不做(如果您检查 phpinfo() 输出的 Xdebug 部分,您会看到这一点).

Xdebug v3 uses different config params than Xdebug v2. From what I see 9 out of 10 "xdebug." params from your current php.ini do nothing in Xdebug v3 (if you would check Xdebug section of the phpinfo() output you would see that).

对于 Xdebug 3,它应该是这样的(基于您的原始配置):

For Xdebug 3 it should be something like this (based on your original config):

zend_extension=xdebug.so
xdebug.mode = debug
xdebug.start_with_request = yes
xdebug.discover_client_host = true
xdebug.client_host = 192.168.33.11
xdebug.client_port = 9001
xdebug.log = /var/www/project.local/.xdebug/xdebug.log
xdebug.idekey = vagrant

这篇关于为什么 Vagrant 和 Xdebug 的组装在最新版本的 PHP 上不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆