【问题标题】:Curl with XDebug on NetBeans在 NetBeans 上使用 XDebug 卷曲
【发布时间】:2014-05-14 10:39:44
【问题描述】:

尝试在 Netbeans(在 Windows 8 上)上使用 Xdebug 调试 curl 请求时,我遇到了一个奇怪的问题。 这是我的代码:

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "http://localhost");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_TIMEOUT, 10);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);

    $response = curl_exec($ch);
    if ( curl_errno($ch) ) {
        $result = 'ERROR -> ' . curl_errno($ch) . ': ' . curl_error($ch);
        echo $result;
    }

    print "\n response = \n";
    var_dump($response);

    // close cURL resource, and free up system resources
    curl_close($ch);

    die;

当我使用 Netbeans 进行调试时,我得到:

ERROR -> 28: Operation timed out after 10015 milliseconds with 0 out of -1 bytes  receivedresponse = bool(false)

当我在没有调试的情况下运行时,我没有收到任何错误和 xampp 页面的响应。

在 php.ini 我有:

[XDebug]
zend_extension = "C:\xampp\php\ext\php_xdebug-2.2.5-5.4-vc9.dll"
xdebug.profiler_append = 0
xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = 0 
xdebug.profiler_output_dir = "C:\xampp\tmp"
xdebug.profiler_output_name = "cachegrind.out.%t-%s"
xdebug.remote_enable = 1
xdebug.remote_handler = "dbgp"
xdebug.remote_autostart = 1
xdebug.remote_host = "127.0.0.1"
xdebug.remote_port = "9000"
xdebug.trace_output_dir = "C:\xampp\tmp"
xdebug.max_nesting_level = 200
xdebug.idekey = "netbeans-xdebug"

【问题讨论】:

    标签: php curl netbeans xdebug


    【解决方案1】:

    我想当您设置xdebug.remote_autostart = 1 时,Xdebug 将始终尝试启动远程调试会话并尝试连接到客户端(即使 GET/POST/COOKIE 变量不存在)。

    在您的情况下,可能是 Xdebug 尝试连接 Netbeans 但无法完成操作,这导致 Xdebug 出现 Operation timeout 错误。

    【讨论】:

    • 我认为你说得有道理。我将 php.ini 修改为此,它似乎工作 [XDebug] zend_extension = "C:\xampp\php\ext\php_xdebug-2.2.5-5.4-vc9.dll" ;xdebug.profiler_append = 0 ;xdebug.profiler_enable = 1 ;xdebug.profiler_enable_trigger = 0 ;xdebug.profiler_output_dir = "C:\xampp\tmp" ;xdebug.profiler_output_name = "cachegrind.out.%t-%s" xdebug.remote_enable = 1 xdebug.remote_handler = "dbgp" ; xdebug.remote_autostart = 1 xdebug.remote_host = "127.0.0.1" xdebug.remote_port = "9000" ;xdebug.trace_output_dir = "C:\xampp\tmp" xdebug.max_nesting_level = 200 xdebug.idekey = "netbeans-xdebug"跨度>
    • @danpop 就我在您的评论中看到的xdebug.remote_autostart 仍然设置为1。可能是笔误?
    • 它前面有一个分号,所以它被注释掉了。干净的配置是这样的: zend_extension = "C:\xampp\php\ext\php_xdebug-2.2.5-5.4-vc9.dll" xdebug.remote_handler = "dbgp" xdebug.remote_host = "127.0.0.1" xdebug.remote_port = "9000" xdebug.max_nesting_level = 200 xdebug.idekey = "netbeans-xdebug"
    • 这项工作非常感谢。断点不会在 curl 请求处停止,但如果文件中有断点,curl 将不会到达那里。
    • @NaseeruddinVN,xdebug 不知道如何跟踪 curl 请求。如果您的 curl 遇到外部 API 怎么办? xdebug 将如何获取源代码,更不用说在它的某个地方中断了?考虑 curl 作为调试的出发点。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-02-05
    • 2014-05-21
    • 2012-06-03
    • 2011-09-03
    • 1970-01-01
    • 1970-01-01
    • 2013-06-17
    相关资源
    最近更新 更多