简体   繁体   English

使用 XDebug 和 XAMPP 从 NetBeans 调试 PHP

[英]Debugging PHP, from NetBeans using XDebug and XAMPP

I have followed this document :我已遵循此文档

This is my php.ini这是我的 php.ini

[XDebug]
zend_extension="C:\xampp\php\ext\php_xdebug.dll"
xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = 1
xdebug.remote_enable = 1
xdebug.remote_host = "localhost"
xdebug.remote_handler = "dbgp"
xdebug.remote_mode = "req"
xdebug.remote_port = 9000

I am running Apache using XAMPP on port 9000:我在端口 9000 上使用 XAMPP 运行 Apache: 在此处输入图像描述

from NetBeans when I do: Debug -> Debug Project从 NetBeans 当我做:调试 - >调试项目

I get the following:我得到以下信息:

Port 9,000 is already in occupied. 9,000 端口已被占用。 Configure the IDE to use another port?将 IDE 配置为使用另一个端口?

在此处输入图像描述

XAMPP is the software that is using port 9000 thousand. XAMPP是使用900万端口的软件。 What do I need to do here?我需要在这里做什么? Should I change the XDebug port to 9001?我应该将 XDebug 端口更改为 9001 吗? Tools -> Options:工具 -> 选项:

在此处输入图像描述 If I do this, I would also need to change php.ini and change the XDebug port to 9001.如果这样做,我还需要更改 php.ini 并将 XDebug 端口更改为 9001。

Or should I keep using port 9000?还是我应该继续使用端口 9000? I have been different settings, but not able to hit my break point.我进行了不同的设置,但无法达到我的断点。

I have been using Netbeans for years to code PHP and xdebug has always been a pain.多年来,我一直在使用 Netbeans 编写 PHP 代码,而 xdebug 一直很痛苦。 I cant even give you any pointers.我什至不能给你任何指示。

But I switched last year to VS code and I can honestly say that it improved my code, and xdebug is actually easy to connect, and fun to use.但我去年改用 VS 代码,老实说,它改进了我的代码,而且 xdebug 实际上很容易连接,而且使用起来很有趣。

I recommend you give it a try.我建议你试一试。

This is how I got the debugger running:这就是我运行调试器的方式:

  1. When prompted with:当提示:

Port 9,000 is already occupied Configure the IDE to use another port?端口 9,000 已被占用 将 IDE 配置为使用另一个端口?

Click Yes (alternatively you can open the setting from Tools -> Options : Choose PHP -> Debugging )单击是(或者您可以从工具打开设置 -> 选项:选择PHP -> 调试

Set debugger Port to 9001.将调试器端口设置为 9001。

在此处输入图像描述

  1. update php.ini to have port 9001更新 php.ini 以拥有端口 9001
[XDebug]
zend_extension="C:\xampp\php\ext\php_xdebug.dll"
xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = 1
xdebug.remote_enable = 1
xdebug.remote_host = "localhost"
xdebug.remote_handler = "dbgp"
xdebug.remote_mode = "req"
xdebug.remote_port = 9001
  1. Restart XAMPP重启XAMPP

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM