Netbeans + Xdebug + php 不工作

发布于 2024-09-03 19:31:36 字数 391 浏览 7 评论 0原文

我的netbeans无法使用xdebug断点,我的配置看起来是正确的,所以我在第一次运行时配置为停止调试,此后第一次从未工作过,有人遇到这个问题吗?我的netbeans版本是6.8,php版本是2.5.2。

我的 php.ini:

zend_extension_ts = d:\wamp\bin\php\php5.2.5\ext\php_xdebug-2.0.2-5.2.5.dll
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.idekey=netbeans-xdebug
xdebug.profiler_enable=1

My netbeans does not work the breakpoints using xdebug, my configuration looks correct, so I configured the first time I ran up to stop debugging the first time since then has never worked, someone had this problem? The version of my netbeans is 6.8 and the version of php is 2.5.2.

my php.ini:

zend_extension_ts = d:\wamp\bin\php\php5.2.5\ext\php_xdebug-2.0.2-5.2.5.dll
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.idekey=netbeans-xdebug
xdebug.profiler_enable=1

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

猛虎独行 2024-09-10 19:31:36

就我而言,这一行需要包含在 php.ini 中:

xdebug.remote_autostart=on

这是 XDebug 的配置部分:

[xdebug]
xdebug.remote_enable = on
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.idekey="netbeans-xdebug"
xdebug.remote_autostart=on
xdebug.profiler_enable = on
xdebug.profiler_enable_trigger = on
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir = "d:/wamp/tmp"

In my case this line needed to be included in the php.ini:

xdebug.remote_autostart=on

Here is the configuration section for XDebug:

[xdebug]
xdebug.remote_enable = on
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.idekey="netbeans-xdebug"
xdebug.remote_autostart=on
xdebug.profiler_enable = on
xdebug.profiler_enable_trigger = on
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir = "d:/wamp/tmp"
风追烟花雨 2024-09-10 19:31:36

xdebug 清单

  1. 检查 xdebug 是否已加载到 phpinfo() 中,以及运行时值 匹配预期配置
  2. xdebug.remote_enable 开启
  3. xdebug.extended_info 应该开启让断点起作用。
  4. xdebug.remote_port 必须与 ide 相同且未使用
  5. xdebug.remote_handlerdbgp
  6. 如果xdebug.remote_autostart<,则xdebug.idekey应设置为与ide的密钥相同 /代码> 已打开。
  7. 有时将xdebug.remote_host设置为内网IP或计算机名称而不是本地IP 127.0.0.1会有所帮助。 PHP 必须防火墙允许才能连接到此主机和端口。
  8. 将 xdebug.remote_log 设置为文件将有助于检查问题所在。调试工作后禁用日志。

示例配置:

[xdebug]
xdebug.extended_info=on
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_autostart=on
xdebug.idekey="netbeans-xdebug"

NetBeans 清单:

  1. 防火墙必须允许 Netbeans 侦听与已配置主机的连接。
  2. 工具->选项-> PHP->调试,检查端口。如果 xdebug.remote_autostart 已打开,还要检查会话 id。
  3. 项目类型必须是 PHP。
  4. 项目属性->来源,网络根目录必须正确。
  5. 项目属性->运行配置,索引文件需要是 php(或空)才能使用 Ctrl+F5。
  6. 项目属性->运行配置->高级调试网址应该“默认”或“每次询问”。
  7. 项目属性->运行配置->高级,路径映射必须正确。 (例如,如果没有映射,则为空)

(大多数默认选项都是开箱即用的,因此,如果您绝望,请尝试删除并重新创建项目。)

错误说明,在 PHP 5.5 和 xdebug 2.2 上进行了测试:

  1. PHP output_buffering 不需要关闭。 (但可能有助于调试)
  2. OPCache(Zend Cache)模块可以加载。
  3. 可以启用xdebug.profiler_enable

如果您发现新内容,请编辑此答案。

Checklist for xdebug:

  1. Check that xdebug is loaded in phpinfo(), and the runtime value matches expected configuration.
  2. xdebug.remote_enable is on.
  3. xdebug.extended_info should be on for breakpoints to work.
  4. xdebug.remote_port must be same as ide and unused.
  5. xdebug.remote_handler is dbgp.
  6. xdebug.idekey should be set to same as ide's key if xdebug.remote_autostart is on.
  7. Sometimes it help to set xdebug.remote_host to intranet IP or computer name instead of local ip 127.0.0.1. PHP must be allowed by Firewall to connect to this host and port.
  8. Setting xdebug.remote_log to a file will help in checking what is wrong. Disable the log once debug is working.

Sample config:

[xdebug]
xdebug.extended_info=on
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_autostart=on
xdebug.idekey="netbeans-xdebug"

Checklist for NetBeans:

  1. Firewall must allow Netbeans to listen for connection with configured host.
  2. Tools -> Options -> PHP -> Debugging, check port. Also check session id if xdebug.remote_autostart is on.
  3. Project type must be PHP.
  4. Project Properties -> Source, web root must be correct.
  5. Project Properties -> Run Configuration, index file need to be a php (or empty) for Ctrl+F5 to work.
  6. Project Properties -> Run Configuration -> Advanced, debug url should be "Default" or "Ask Everytime".
  7. Project Properties -> Run Configuration -> Advanced, path mapping must be correct. (e.g. empty if there are no mappings)

(Most default options work out of the box, so if you are desperate try to delete and recreate the project.)

False Instructions, tested on PHP 5.5 and xdebug 2.2:

  1. PHP output_buffering does not need to be off. (But may help in debugging)
  2. OPCache (Zend Cache) module can be loaded.
  3. xdebug.profiler_enable can be enabled.

Please edit this answer if you found something new.

回心转意 2024-09-10 19:31:36
  • 检查您的 Xdebug 版本是否适合您的 PHP 版本(包括线程安全/非线程安全和 64 位/32 位)。
  • 在一些较新版本的 PHP 中,无论您是否有 TS 版本的 Xdebug,都需要使用 zend_extension,而不是 zend_extension_ts。
  • Check that you have the right version of Xdebug for your version of PHP (including Thread-safe/non-thread-safe and 64bit/32bit).
  • In some newer versions of PHP, you need to use zend_extension, not zend_extension_ts, regardless of whether you have the TS version of Xdebug.
我ぃ本無心為│何有愛 2024-09-10 19:31:36

(我正在回复答案,因为评论中的格式无法正常工作)

我也发生了同样的事情:工作一次然后停止。然而,我的配置达到了一个点,它开始正常工作,没有问题,我可以分享。

首先,我将 ioncube 加载器移至 php.ini 之上:

[PHP]
zend_extension=/Applications/MAMP/bin/php5/zend/lib/ioncube_loader_dar_5.2.so

然后我将这些行放入 xdebug 配置中:

[xdebug]
zend_extension="/Applications/MAMP/bin/php5/lib/php/extensions/no-debug-non-zts-20060613/xdebug.so"
xdebug.default_enable=1
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000

并注释掉有关 Zend Optimizer

[Zend]
;zend_optimizer.optimization_level=15
;zend_extension_manager.optimizer=/Applications/MAMP/bin/php5/zend/lib/Optimizer-3.3.3
;zend_optimizer.version=3.3.3

我在 MAMP 上工作的所有行,这就是为什么我的库的路径引用我的 MAMP文件夹。

祝你好运

(I am replying with an Answer since the formatting in comments wasn't working properly)

Same happened for me: worked once and then stopped. However, I reached a point in my config where it started working without problems and I can share.

First I moved on top of php.ini the ioncube loader:

[PHP]
zend_extension=/Applications/MAMP/bin/php5/zend/lib/ioncube_loader_dar_5.2.so

Then I put these lines in the xdebug config:

[xdebug]
zend_extension="/Applications/MAMP/bin/php5/lib/php/extensions/no-debug-non-zts-20060613/xdebug.so"
xdebug.default_enable=1
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000

And commented out all the lines about Zend Optimizer

[Zend]
;zend_optimizer.optimization_level=15
;zend_extension_manager.optimizer=/Applications/MAMP/bin/php5/zend/lib/Optimizer-3.3.3
;zend_optimizer.version=3.3.3

I work on MAMP, this is why the paths to my libraries are referred to my MAMP folder.

Good luck

娇纵 2024-09-10 19:31:36

zend_extension = "C:\xampp\php\ext\php_xdebug-2.2.3-5.4-vc9.dll"xdebug.remote_enable = 1 xdebug.remote_handler = "dbgp"xdebug.remote_host = "localhost" xdebug.remote_port= "9000" xdebug.remote_mode=req xdebug.trace_output_dir = "C:\xampp\tmp" xdebug.idekey="netbeans-xdebug"

这对我有用..

zend_extension = "C:\xampp\php\ext\php_xdebug-2.2.3-5.4-vc9.dll"xdebug.remote_enable = 1 xdebug.remote_handler = "dbgp"xdebug.remote_host = "localhost" xdebug.remote_port="9000" xdebug.remote_mode=req xdebug.trace_output_dir = "C:\xampp\tmp" xdebug.idekey="netbeans-xdebug"

this is working for me..

水溶 2024-09-10 19:31:36

以下是我如何让它在多个 PHP-FPM 自制软件安装中工作。

我将这篇优秀的文章用于多个安装:

https://echo.co/blog/os-x-1010-yosemite-local-development-environment-apache-php-and-mysql-homebrew

在那篇文章的评论中,您'您将看到建议的如何安装 xdebug,底线

brew install php56-xdebug

您必须为已安装的每个 PHP 版本安装 xdebug。 Homebrew 将为您安装的每个版本的 php 制作一个 xdebug.ini 文件。每个都有这样的路径:

/usr/local/etc/php/<version # i.e. "5.6">/conf.d/ext-xdebug.ini

本文安装了在 xdebug 的默认端口 (9000) 上运行的 DNSMasq,因此您需要将 xdebug 端口更改为其他端口(9001 工作正常。)

编辑上面提到的 ext-xdebug.ini 文件(如果您安装了多个版本的 php,则为文件。) 以下是对我有用的内容:

[xdebug]
zend_extension="/usr/local/opt/php56-xdebug/xdebug.so"

; General config
; Dumps local variables on exception
xdebug.show_local_vars=On
; Dump server variables
xdebug.dump.SERVER=*
; Dump global variables
xdebug.dump_globals=On
xdebug.collect_params=4;

; Tracing
;xdebug.auto_trace=On
;xdebug.trace_output_dir= /opt/local/php_traces/
xdebug.show_mem_delta=On
xdebug.collect_return=On


; Debugging. You might need to specify your host with some additional options
xdebug.remote_enable=1
: from http://devzone.zend.com/1147/debugging-php-applications-with-xdebug/
xdebug.remote_host="localhost"
xdebug.remote_port=9001
xdebug.remote_handler="dbgp"

前两行是原始自制文件中的全部内容。

顺便说一句 - 当我安装多个 PHP 版本时,此 ext-xdebug.ini 文件仅为我安装的第一个 PHP 版本创建。我只是将此文件复制到其他 PHP 版本位置,并更改第 2 行中路径的“php56-xdebug”部分以反映正确的 PHP 版本。

注意“xdebug.remote_port=9001”,

然后在 Netbeans 中(我使用的是 8.02 Mac osX10.10.3),我使用以下设置。
转到首选项->PHP->调试

调试器端口:9001

停在第一行:(未选中

Watches &气球评估:(检查 - 有一个警告,但它对我来说效果很好。)

还值得注意的是,为了让 xdebug 使用 phpinfo() (或命令行 php -i)显示,我需要重新启动apache:

launchctl unload -Fw ~/Library/LaunchAgents/homebrew.mxcl.php56.plist

sudo apachectl restart

launchctl load -Fw ~/Library/LaunchAgents/homebrew.mxcl.php56.plist

出于某种原因,我的设置要求我每次启动时都运行它。有点痛苦,但我将其合并到 shell 命令中以轻松在版本之间切换。

还有一个提示:brew info php56 的一部分说:

OS X 10.8 and newer come with php-fpm pre-installed, to ensure you are using
the brew version you need to make sure /usr/local/sbin is before /usr/sbin
in your PATH:

  PATH="/usr/local/sbin:$PATH"

在我将其添加到我的 .profile_bash 文件之前,我对每个版本的 php-fpm.conf 文件所做的更改都无法识别。其他一切似乎都有效,所以很混乱。

希望这可以节省其他人的时间和时间。麻烦。

Here's how I was able to get it to work w/ mulitple PHP-FPM homebrew installations.

I used this excellent article for the multiple installations:

https://echo.co/blog/os-x-1010-yosemite-local-development-environment-apache-php-and-mysql-homebrew

In the comments of that post you'll see recommended how to install xdebug, bottom line:

brew install php56-xdebug

You have to install xdebug for each verions of PHP you have installed. Homebrew will make a xdebug.ini file for each version of php you installed. Each will have a path like:

/usr/local/etc/php/<version # i.e. "5.6">/conf.d/ext-xdebug.ini

This article installs DNSMasq which runs on xdebug's default port (9000), so you'll need to change the xdebug port to something else (9001 works fine.)

Edit the above mentioned ext-xdebug.ini file (or files if you installed more than one version of php.) Here's what works for me:

[xdebug]
zend_extension="/usr/local/opt/php56-xdebug/xdebug.so"

; General config
; Dumps local variables on exception
xdebug.show_local_vars=On
; Dump server variables
xdebug.dump.SERVER=*
; Dump global variables
xdebug.dump_globals=On
xdebug.collect_params=4;

; Tracing
;xdebug.auto_trace=On
;xdebug.trace_output_dir= /opt/local/php_traces/
xdebug.show_mem_delta=On
xdebug.collect_return=On


; Debugging. You might need to specify your host with some additional options
xdebug.remote_enable=1
: from http://devzone.zend.com/1147/debugging-php-applications-with-xdebug/
xdebug.remote_host="localhost"
xdebug.remote_port=9001
xdebug.remote_handler="dbgp"

The first two lines are all that is in the original homebrew file.

BTW - when I installed multiple PHP versions, this ext-xdebug.ini file was only created for the first PHP version I installed. I simply copied this file to the other PHP version locations, and changed the "php56-xdebug" part of the path in line 2 to reflect the proper php version.

Notice "xdebug.remote_port=9001"

Then in Netbeans (I'm using 8.02 Mac osX10.10.3) I use the following settings.
Go to Preferences->PHP->Debugging

Debugger Port: 9001

Stop at First Line: (unchecked)

Watches & Balloon Evaluation: (checked - there's a warning but it works fine for me.)

Also worth noticing is that in order for xdebug to show up using phpinfo() (or command line php -i) I need to restart apache with:

launchctl unload -Fw ~/Library/LaunchAgents/homebrew.mxcl.php56.plist

sudo apachectl restart

launchctl load -Fw ~/Library/LaunchAgents/homebrew.mxcl.php56.plist

For some reason my setup requires me to run this every time I startup. Kind of a pain, but I incorporated it in a shell command to easily switch between versions.

One more hint: part of brew info php56 says:

OS X 10.8 and newer come with php-fpm pre-installed, to ensure you are using
the brew version you need to make sure /usr/local/sbin is before /usr/sbin
in your PATH:

  PATH="/usr/local/sbin:$PATH"

Until I added this to my .profile_bash file, changes I made to each version's php-fpm.conf file were not recognized. Everything else seemed to work so it was confusing.

Hope this saves someone else time & trouble.

猫性小仙女 2024-09-10 19:31:36

如果您仍然遇到困难,可以尝试以下操作:

  • 通过向导下载新版本的 xdebug (http:// www.xdebug.org/wizard.php),如果您按照说明进行操作,也许您会很幸运。
  • 关闭防火墙可能会有所帮助。
  • 在 netbeans 中使用不同的端口,例如在我的例子中,在 netbeans 中使用 9001 ,在 xdebug 中使用 9000 有效。
  • 添加到 php.ini 文件:xdebug.idekey=netbeans-xdebug
  • 查明您是否有 xdebug.ini 文件,并将与 xdebug 相关的 php.ini 行添加到该文件中。

始终确保重新启动 apache 服务来测试一切。

If you are still stuck you could try the following:

  • Download a new version of xdebug via the wizard (http://www.xdebug.org/wizard.php) and if you follow the instructions maybe you will be lucky.
  • Switching off the firewall might help.
  • Use a different port in netbeans, for instance in my case using 9001 in netbeans and 9000 in xdebug worked.
  • Add to php.ini file: xdebug.idekey=netbeans-xdebug.
  • Find out if you have a xdebug.ini file and add the xdebug related php.ini lines to that file.

Always make sure that you restart your apache service to test everything.

水中月 2024-09-10 19:31:36

就我而言 - 主机位于另一台服务器 Net-beans 11 上 - 我需要打开远程主机的终端

Window -> IDE 工具 ->终端->远程终端

PS如果您在该终端中输入 export XDEBUG_CONFIG="idekey=netbeans-xdebug" 并启动调试会话,您可以调试控制台脚本

In my case - host is on another server, Net-beans 11 - I need to open terminal to remotehost

Window -> IDE Tools -> Terminal -> Remote Terminal

P.S. If u type export XDEBUG_CONFIG="idekey=netbeans-xdebug" in that terminal, and start debugging session, u can debug console scripts

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文