[Tutorial] How to add Xdebug to Laragon

  • administrators
    | 132019 points

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

    1. Copy phpinfo() content:

    2. Paste the copied data to the form in the Xdebug Wizard page

    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.

  • | 6284 points

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

  • | 524 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:
    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.remote_enable= 1
    xdebug.remote_autostart = 1

  • | 3254 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 )

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

  • | 524 points

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

  • | 997 points

    What is the purpose of the PHP -> Quick Settings -> xdebug option? Clicking it restarts Apache & Nginx but doesn't disable xdebug (once installed per above method).

    Is it purely for notification purposes?

  • | 6284 points

    @danieliser kinda a good question. As I understand it, it should really toggle xdebug on and off. So it sounded great but I haven't got it to work yet. (To enable xdebug, I followed the above instructions; and to disable it, I remove the xdebug lines from my php config file, save, and restart Laragon)
    You should probably start a separate topic with your question IMO

  • | 524 points

    Ugh! My xdebug has stopped working in web mode, though running it with a local script works ok. It doesn't appear to be listening to the web server at all.

  • | 6284 points

    @Michael-Chean that's a mystery alright. You should probably create a new issue (feel free to ping me and I'll try to help)

  • | 524 points

    @mnelson4 Thank you, it was a boneheaded mistake on my part - sorry. Reinstalled using PHP Tools for VS Code and it worked.

  • administrators
    | 132019 points

    @mnelson4 , @danieliser: I've released Laragon 3.5 which works well with xdebug in PHP 7.2+.

  • | 524 points

    I finally gave up on doing this myself. I'm using VSCode so I was able to install PHP Tools for VS Code by Devsense which installs Xdebug and some other useful tools. So far no problems!

  • | 1008 points

    From the documentation on the official github page for VSCode PHP Debug extension, seems like all you need to do is to add xdebug.remote_connect_back = 1 to [Xdebug] section in php.ini. This will work for other clients too, not only VSCode with this extension. I think that vhosts are causing this problem and remote_connect_back tells the client what server address it should listen to

  • | 1372 points

    This worked with vscode+laragon:

    launch.json (vscode)---------------------------
    "name": "Listen for XDebug",
    "type": "php",
    "request": "launch",
    "cwd": "${workspaceRoot}",
    "port": 9000

    add this to end of php ini: ----------------------------------
    zend_extension = W:\laragon\bin\php\php-7.2.11-Win32-VC15-x64\ext\php_xdebug-XXXXXXXXXX.dll
    xdebug.remote_enable = 1
    xdebug.remote_host = localhost
    xdebug.remote_port = 9000
    xdebug.remote_connect_back = 1

    Debugging works, but the quick settings in Laragon does not work, i think it needs to set the "xdebug.remote_enable" to false when not used?

  • | 1008 points

    @martinandersen3d I think you're "overthinking" it. If you have correct ext path (which you should), you only need to provide zend_extension=php_xdebug.dll.

    I also use default configuration that VSCode creates and it works out of the box. My variables look like this (I also have profiler enabled by setting the debug variable XDEBUG_PROFILE - can be found in the docs)


    Regarding the Quick Settings, make sure you have only one mention of zend_extension=php_xdebug.dll and only one dll in ext directory. If all conditions are met, Laragon will disable the line as expected.

    Above works for me for PHP5.6, PHP7.1, PHP7.2, PHP7.3 with Apache/Nginx configuration, latest compatible release of xdebug and Laragon 4.0.x (currently 4.0.12)

  • | 1372 points

    Thanks P Mo. It works :-)

    I've created a Hotkey to toggle xDebug On/Off.


    Get it here:


    Demo video:

    Overkill i guess :dancer_tone1: :D

  • | 383 points

    Have anyone tried adding xdebug to PHP 7.4 RC2 NTS? I had no sucess even tho i've followed the instructions provided my xdebug site:

    • Download php_xdebug-2.8.0beta2-7.4-vc15-nts-x86_64.dll
    • Move the downloaded file to C:\laragon\bin\php\php-7.4.0RC2-nts-Win32-vc15-x64\ext
    • Edit C:\laragon\bin\php\php-7.4.0RC2-nts-Win32-vc15-x64\php.ini and add the line
    • zend_extension = C:\laragon\bin\php\php-7.4.0RC2-nts-Win32-vc15-x64\ext\php_xdebug-2.8.0beta2-7.4-vc15-nts-x86_64.dll
    • Restart the webserver

  • | 1008 points

    @SHJordanSLIM it's not your fault, it's not working properly with TS too .. basically I don't need to do anything for new PHP versions and xDebug integration, just copy the file, rename to php_xdebug.dll and Laragon does the rest .. it's working fine for me with PHP5.6&xDebug2.5.5 and PHP7.1/7.2/7.3&xDebug2.7.2 .. PHP7.4&xDebug2.8.0 is not working for now

  • | 716 points


    To change the version of php you just have to download the version you need according to your architecture at http://windows.php.net/download/, and then leave in the php path in the example case it was C: \ laragon \ bin \ php


    In the case of laragon the dll extension is done in the extensions menu because it did not give good results it was added manually in php.ini

    Configure php.ini

    And add the following:
    zend_extension = "C: \ laragon \ bin \ php \ php-7.2.0-Win32-VC15-x64 \ ext \ php_xdebug-2.6.0beta1-7.2-vc15-x86_64.dll"

    xdebug.default_enable = 1
    xdebug.remote_autostart = 1
    xdebug.remote_host = localhost
     xdebug.remote_enable = on
    xdebug.remote_handler = dbgp
    xdebug.remote_mode = req
    xdebug.idekey = "php-vs"
    xdebug.profiler_append = 0
    xdebug.profiler_enable = 0
    xdebug.profiler_enable_trigger = 1

    Generate restart in the apache service session. Also as a reference the configuration in laragon is:


    2.2 Xdebuger:

    Enter https://xdebug.org/wizard.php, enter http: // localhost /? Q = info on this page you get all the code that I give you phpinfo.php

    You enter this content on the Xdebuger section wizard page

    And follow the instructions that indicate the result of the page.

    The dll leave in C: \ laragon \ bin \ php \ php-7.2.0-Win32-VC15-x64 \ ext


    2.3 VSCODE




Log in to reply

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