Simultaneous debugging sessions in PhpStorm

When building web applications with multiple tiers, we can have a situation in which frontend PHP code calls into backend PHP code. It’s easy to use remote debugging on the frontend, but what if we wanted to debug both sides at the same time?

By default, PhpStorm accepts only one debugger connection at a time. There are several reasons for this, for example when making extensive use of AJAX a lot of incoming debugger connections may be created making debugging virtually impossible.

On a per-project basis, we can enable support for having more than one debugger connection. Through the File | Settings menu and then PHP | Debug, we can beef up the maximum number of simultaneous connections from 1 to a larger number.

Note that for debugging to work, we must configure PHP and enable the PHP Debug Connections listener in PhpStorm. More on this can be found in our new tutorials space.

Let’s put this to the test. As an example, I’ve created two simple files where frontend.php makes a call to backend.php.

After placing a breakpoint in both files, we can run our code on our local webserver and call into frontend.php from a browser. When stepping through the code, PhpStorm will open a new debug session for backend.php once it gets called by the frontend code.

As always, we appreciate your feedback in the comments below or in our forums!

Develop with pleasure!
– JetBrains Web IDE Team

This entry was posted in Cool Feature and tagged , , . Bookmark the permalink.

5 Responses to Simultaneous debugging sessions in PhpStorm

  1. goyote says:

    I use to debug an application hosted inside a virtual machine, now no matter what my settings I can get a connection to work. Does jetbrains offer any paid support?

  2. Ronald says:

    Thanks for that tipp. I was using a VM with the frontend there deployed and calling the backend for debugging. And that is pain that way. I’ll try that tomorrow.

  3. Faisal says:

    This does not seem to work if the frontend and backend code bases are in separate PHPStorm projects.

    Do we have to have all code bases in the same PHPStorm project in order to debug a tiered application?

    • Maarten Balliauw says:

      If you have on PhpStorm instance listen for connections, it will ask you to locate the other project’s files if needed and use those for debugging.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">