How to get Xdebug working on PhpStorm with PHP 8 in April 2024

Notes to self that might also help you…

After struggling for too long, I followed the nuclear route at Xdebug nightmare - #8 by Glauber (no longer open to replies or else I would have) as a starting point.

Since it worked, I compared why it worked vs my existing PhpStorm project’s settings and the only difference was the port.

So to find the port# you need, go to your phpinfo() output and see $_SERVER['SERVER_PORT']
You could also acquire this on Mac by going to this file in Finder: ~/Library/Application Support/Local/run/router/nginx/conf/route.YOURSITE.local.conf

You don’t need Path Mappings or anything else. This works:

Then you setup your Configuration, then Validate should work (green check marks):

Of course, all the other Xdebug stuff applies, but you do NOT need a browser extension, and you do not need the “Xdebug + PhpStorm” LocalWP extension - although it’d make sense if it correctly added the port# instead of inserting as 80 - therefore, this is a bug report for that extension.

LocalWP v9.0.1+6673
Xdebug + PhpStorm extension v2.0.2
PHP 8.0.30
macOS 14.4.1

Thank you so much for these notes @cliff !

As part of cleaning up and sunsetting Addons that are no longer needed, we created a Local Help Doc that mimics the info in this forum topic:

3 Likes

I skimmed through and it looked like a thorough article! :slight_smile:
But, I did not see mention of this part:

So to find the port# you need, go to your phpinfo() output and see $_SERVER['SERVER_PORT']
You could also acquire this on Mac by going to this file in Finder: ~/Library/Application Support/Local/run/router/nginx/conf/route.YOURSITE.local.conf

When I was going through the article, I didn’t need to use a port – PhpStorm was able to get things working. I was using the “Site Domains” router mode so maybe that was playing into it.

The server port number should automatically be set in step 6 from the walkthrough, when you’re prompted by PhpStorm to accept the incoming connection from Xdebug. You should no longer have to set it manually.

CleanShot-2025-04-08-at-17.27.43

1 Like

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.