dongranding3909 2018-02-01 21:58
浏览 75
已采纳

PhpStorm + Xdebug远程调试冻结了

I have set PHP debugging with Xdebug on PhpStorm to hit a localhost. Everything works fine with "smart PHP listening" or manual debug run unless I have got to the point where code looks like

$aOptions = array (
        'http' => array (
                'header' => "Content-Type: application/x-www-form-urlencoded
$sBits",
                'method' => 'POST',
                'content' => http_build_query ( $aData )
        )
);

$rContext = stream_context_create ( $aOptions );
$sResult = file_get_contents ( $sUrl, false, $rContext );
return \json_decode ( $sResult );

and got stuck on a line

$sResult = file_get_contents ( $sUrl, false, $rContext );

with an error message

file_get_contents(http://localhost:8888/data/?/Ajax/&q[]=/0/): failed to open stream: HTTP request failed!

but when I run debug after that line will pass all work fine.

PhpStorm and Xdebug has already set

  • Settings | PHP | Debug | Max simultaneous connections --> 5.

xdebug.remote_autostart = 1

Any clue why Xdebug hangs on it when without debugging it can pass w/o any issue?

  • 写回答

2条回答 默认 最新

  • doudie2693 2018-02-02 17:07
    关注

    Based on JetBrains documentation for simultaneous debugging sessions I was able to get it fixed by adding suggested code to start debugger session for child requests as follow

    $aOptions = array (
            'http' => array (
                    'header' => "Content-Type: application/x-www-form-urlencoded
    $sBits",
                    'method' => 'POST',
                    'content' => http_build_query ( $aData )
            )
    );
    
    $debuggingQuerystring = '';
    if (isset($_GET['XDEBUG_SESSION_START'])) { // xdebug
         $debuggingQuerystring = '?XDEBUG_SESSION_START=' . $_GET['XDEBUG_SESSION_START'];
    }
    if (isset($_COOKIE['XDEBUG_SESSION'])) { // xdebug (cookie)
         $debuggingQuerystring = '?XDEBUG_SESSION_START=PHPSTORM';
    }
    
    $rContext = stream_context_create ( $aOptions );
    $sResult = file_get_contents ( $sUrl.$debuggingQuerystring, false, $rContext );
    return \json_decode ( $sResult );
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 fastreport怎么判断当前页数
  • ¥15 Kylin-Desktop-V10-GFB-Release-JICAI_02- 2207-Build14-ARM64.iso有没有这个版本的系统啊
  • ¥15 能不能通过蓝牙将传感器数据传送到手机上
  • ¥20 100元python和数据科学实验项目
  • ¥15 根据时间在调用出列表
  • ¥15 R 包chipseeker 安装失败
  • ¥15 Veeam Backup & Replication 9.5 还原问题
  • ¥15 vue-print-nb
  • ¥15 winfrom的datagridview下拉框变成了黑色,渲染不成功
  • ¥20 利用ntfy实现短信推送