PhpStorm当JS启动请求时,我如何调试php文件

PhpStorm how I debug php file when request is initiated from JS?

本文关键字:何调试 调试 文件 php JS 启动 请求 PhpStorm      更新时间:2023-09-26

我独立调试php文件没有问题,但当我想看到服务器的请求时side(php)从客户端本地获取,我不能。我试图通过将断点放在php文件中来实现这一点,希望当我使用chrome调试项目时,调试器会在断点处停止。

我的php看起来是这样的:

<?php
    $response = "Super"  <--this line has a breaking point
    echo $response

客户端向服务器端发送请求如下:

    function ajaxRequest(url, data, requestMethod)
    {
        $.ajax({
            type: requestMethod,
            url: url,
            data: {
                json: data
            },
            success: responseHandler
        });
    }

当我在调试中运行项目时,我会在chrome中获得带有以下url的窗口:http://localhost/Jason/index.html?XDEBUG_SESSION_START=19067

在我的PHPStorm调试器中,我看到正在等待与ide密钥19067的连接chrome显示给代码,就好像请求已经发送,响应已经接收,而没有在php断点中停止。

启动php调试后,尝试在浏览器窗口中右键单击,然后在PhpStorm中选择Inspect。这也应该激活风暴中的JS调试器和php调试。

当然,您已经为PhpStorm安装了Chrome扩展:https://chrome.google.com/webstore/detail/jetbrains-ide-support/hmhgeddbohgjknpmjagkdomcpobmllji

希望这能有所帮助。

[后期编辑]啊,停用你可能拥有的任何JavaScript缩小!