Canttouchit
Canttouchit

Reputation: 3159

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

I have no issue debugging php files independently but when I want to see the request that server side(php) get from client side locally, I can't. I try to do it by putting breaking point inside php file, hopefully debugger will stop on break point when I debugging my project using chrome.

My php looks like that:

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

Client side sending the request to server side looks like that:

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

When I run project in debug I get window in chrome with this url: http://localhost/Jason/index.html?XDEBUG_SESSION_START=19067

And in my PHPStorm debugger I see waiting for connection with ide key 19067 The chrome is displaying to code as if the request already been sent and response has been received without stopping in php break point.

Upvotes: 2

Views: 2941

Answers (1)

Marius Vetrici
Marius Vetrici

Reputation: 34

After you start php debugging, try to right click in the browser window and select Inspect in PhpStorm. This should also activate the JS debugger in storm alongside php debug.

Of course you've installed Chrome extension for PhpStorm: https://chrome.google.com/webstore/detail/jetbrains-ide-support/hmhgeddbohgjknpmjagkdomcpobmllji

Hope this helps.

[Later edit] Ah, and deactivate any JavaScript minifying you may have!

Upvotes: 1

Related Questions