How to get Xdebug to work on v5.0.7+

Wanted to post this here to help everyone who may be experiencing issues with Xdebug and phpstorm not working anymore. Since updating from Local by Flywheel to Local Lightning, Xdebug has discontinued working because the PHP module php-fpm listens on the default xdebug port of 9000. Change the setting ‘xdebug.remote_port’ to 9009 (as long as no other service/worker is listening in on 9009) in phpstorm and restart your site. Xdebug will work again!

3 Likes

Sentence correction:

Change the setting ‘xdebug.remote_port’ to 9009 (as long as no other service/worker is listening in on 9009) in your site’s php.ini file and in phpstorm’s (or other IDE) Xdebug listening port setting. Restart your site to have the changes take effect.

In case anyone else comes across this and is a bit unclear…

/Users/YOU/Dropbox/local-sites/SITE/conf/php/php.ini.hbs is the correct file to edit. It’s got this extra “.hbs” to be a Handlebars file.

Open this file in a text editor (like PhpStorm), search for “xdebug”, and make your changes, like I did:

xdebug.remote_enable=1
;xdebug.remote_connect_back=Off
;xdebug.remote_port="9000"
;xdebug.profiler_enable=0

; Below was added by Cliff. Commented lines above are just to keep record of what the defaults were.
xdebug.remote_port=9001
;xdebug.remote_enable=1
xdebug.remote_autostart=1
xdebug.remote_connect_back=1
xdebug.var_display_max_depth=-1
xdebug.var_display_max_children=-1
xdebug.var_display_max_data=-1
;xdebug.profiler_enable=1
xdebug.profiler_output_dir="/Users/YOU/Dropbox/local-sites/SITE/app/public/_xdebug-profiling/" ;make sure folder already exists

Then right-click your site in Local app and click “Restart” for your changes to take effect.

Then set your PhpStorm to listen at the right port (9001 in my case), setup the index.php path, and it works: https://share.getcloudapp.com/v1urN7bg (1min gif demo)

I have tried changing the port to a free one but it’s still not working. I’m currently working off of Local 5.2.5 with VS Code.

Any other ideas on how to get Xdebug to work on this version?

Thanks!

I was struggling with this again, too!

Turns out the site was loading via HTTP instead of HTTPS (imported the HOME/SITE URLs from a public site on HTTP)

Once I changed from HTTP to HTTPS, Xdebug started working, as documented above.

You can force to HTTPS in your General Settings (HTTP --> HTTPS) or add Nginx/Apache redirect from this other thread.

But then after it did trigger (only after on HTTPS), it also triggered on HTTP… so maybe it was because I added Path Mappings once the prompt triggered when hit via HTTPS