[Tutorial] How to add Xdebug to Laragon
You can add Xdebug to Laragon easily.
Method 1: Using phpinfo() & Xdebug Wizard
Copy phpinfo() content:
Paste the copied data to the form in the Xdebug Wizard page
Click "Analyse my phpinfo() output", and follow the instructions.
Note: Their instructions will ask for "4. Restart the webserver" but with Laragon, you just need to click Reload button.
@leokhoa I found I also needed to add
php.inifile. Otherwise, those steps worked great.
Still can't get it to work. I place a break in my php program then open it in my Chrome browser and launch it using:
I've got it working in XAMPP though.
My phpinfo reports:
This program makes use of the Zend Scripting Language Engine:
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
with Xdebug v2.6.1, Copyright (c) 2002-2018, by Derick Rethans
Add the following 3 lines to php.ini
xdebug.remote_autostart = 1
xdebug.remote_enable=1if you plan to contact a debug client. Which I would suspect a lot of people would/should. However, it's not required, its just one feature of xDebug. You can still get a lot of value from xDebug even if it's turned off (which it is by default).
Also by off by default is
xdebug.remote_autostart=1will force xDebug to always attempt to connect to the remove client, regardless if the
XDEBUG_SESSIONis properly set. I actually don't believe this should be recommended for all. Most users should leave this off and use the
XDEBUG_SESSIONcookie instead. There are many browser plugins that can set this for you, and I should think that would be the recommended way. Remote debugging carries a large performance hit, and I've seen it cause issues in some edge cases. So I would think most people would only want that when they are actually stepping through code, and not every single time you make a request to the website. To each their own, but I felt it was important to point out just in case a reader was not familiar with what these settings do.
( Here are the all the setting if you want to read more: https://xdebug.org/docs/all_settings )
Here are the plugins/extensions from https://xdebug.org/docs/remote if interested...
- Xdebug Helper for Firefox ( https://addons.mozilla.org/en-GB/firefox/addon/xdebug-helper-for-firefox )
- Xdebug Helper for Chrome ( https://chrome.google.com/extensions/detail/eadndfjplgieldjbigjakmdgkmoaaaoc )
- Xdebug Toggler for Safari ( https://github.com/benmatselby/xdebug-toggler )
- Xdebug launcher for Opera
...You would use these as one option instead of setting
xdebug.remote_autostart=1. Or you could just set the cookie manually, or by script, etc. More information on remote debugging is on that page as well.
@pfaciana thank you - this is way over my head at the moment, but it gives me something to look into.