[Tutorial] How to add Xdebug to Laragon


  • administrators
    | 89404 points

    You can add Xdebug to Laragon easily.
    Method 1: Using phpinfo() & Xdebug Wizard

    1. Copy phpinfo() content:
      http://localhost/?q=info

    2. Paste the copied data to the form in the Xdebug Wizard page
      https://xdebug.org/wizard.php

    3. 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.


  • | 3473 points

    @leokhoa I found I also needed to add xdebug.remote_enable=1 to the php.ini file. Otherwise, those steps worked great.


  • | 84 points

    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:
    http://localhost:8080/operators.php
    No luck.
    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

    Solution found:
    Add the following 3 lines to php.ini
    [xdebug]
    xdebug.remote_enable= 1
    xdebug.remote_autostart = 1


  • | 3091 points

    You need xdebug.remote_enable=1 if 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 remote_autostart. Setting xdebug.remote_autostart=1 will force xDebug to always attempt to connect to the remove client, regardless if the XDEBUG_SESSION is properly set. I actually don't believe this should be recommended for all. Most users should leave this off and use the XDEBUG_SESSION cookie 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 )


  • | 3091 points

    Here are the plugins/extensions from https://xdebug.org/docs/remote if interested...

    ...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.


  • | 84 points

    @pfaciana thank you - this is way over my head at the moment, but it gives me something to look into.


Log in to reply
 

Looks like your connection to Laragon was lost, please wait while we try to reconnect.