简体   繁体   English

PHP cli远程调试器问题

[英]PHP cli remote debugger issue

I have this problem: I'm trying to debug PHP scripts ran over CLI (I don't care about doing so over a web server) either remotely - preferably - or locally. 我有这个问题:我正在尝试调试运行在CLI上的PHP脚本(我不关心在Web服务器上这样做)远程 - 最好 - 或本地。

I'm on Linux both on the remote server and my development local machine using xdebug, and either netbeans/eclipse remotely or vdebug on vim locally. 我使用xdebug在远程服务器和开发本地机器上使用Linux,远程使用netbeans / eclipse或在本地使用vdebug。

So my issue is this: the remote machine runs PHP scripts in the background since we're using them for system tasks, resource monitoring, etc. So while I'm trying to debug script A (which I'm working on), the debugger ends up showing me the cron'ed scripts that are being ran at the same time, making it impossible to work on what I'm doing at the time. 所以我的问题是:远程机器在后台运行PHP脚本,因为我们将它们用于系统任务,资源监控等。所以当我尝试调试脚本A(我正在研究)时,调试器最终向我展示了同时运行的cron'ed脚本,这使我无法处理我当时正在做的事情。

Am I doing something wrong? 难道我做错了什么? I've tried a number of approaches but I keep running into this problem. 我尝试了很多方法,但我一直遇到这个问题。

My current configuration is this, but I've tried a multitude of variations. 我目前的配置是这样的,但我尝试了很多变化。

zend_extension = /usr/lib64/php/modules/xdebug.so
xdebug.remote_enable = on
xdebug.remote_handler = dbgp
xdebug.remote_host = 127.0.0.1
xdebug.remote_port = 9000
xdebug.remote_autostart = On

Thoughts? 思考?

As far as I understood the question your IDE is run on different machine than script runs. 据我所知,您的IDE运行在与脚本运行不同的机器上。 In this case the option 在这种情况下选项

xdebug.remote_host = 127.0.0.1

should be the host where your IDE runs. 应该是运行IDE的主机。

Make sure you configure idekey as well as Eclipse itself properly. 确保正确配置idekey以及Eclipse本身。

Also make sure that the config you have is in php.ini for CLI, not for Apache. 还要确保您的配置是用于CLI的php.ini,而不是Apache。

The problem was that I had xdebug.remote_autostart set. 问题是我设置了xdebug.remote_autostart。 Every PHP script that started ended up being passed through the debugger whether it was the one I was working on or not. 每个启动的PHP脚本最终都会通过调试器传递,无论是否是我正在处理的那个。

The relevant part of xdebug's documentation is this: When running the script from the command line you need to set an environment variable, like: export XDEBUG_CONFIG="idekey=session_name" php myscript.php xdebug文档的相关部分是:从命令行运行脚本时,需要设置一个环境变量,如:export XDEBUG_CONFIG =“idekey = session_name”php myscript.php

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

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