PHP 8 & Xdebug .....

  • | 1735 points

    PHP 8

    New to Laragon, and can't get Xdebug to work although it is a fresh install for both.

    PHP 8 has been downloaded here

    This is the error when trying to load Xdebug.

    The PHP.ini file gives the right location

    Not sure where the settings are wrong......

  • | 16270 points

    @DickVG I've written a blog which has a section for Xdebug: Standard setup for PHP projects 2021/#Xdebug, I hope this information helps.

  • | 16270 points

    @DickVG I've just noticed you are trying to load the non-thread safe (NTS) version of Xdebug in a thread-safe (TS) version of PHP.

    PHP has 4 versions available to download, 32-bit or 64 bit, Thread Safe (TS) or Non Thread Safe (NTS). For Laragon v5 you would use 64 bit. Apache requires the Thread Safe (TS) version, Internet Information Services (IIS) requires the Non-Thread Safe version (NTS). The version of Xdebug needs to match the version of PHP, so in your case, you would need Xdebug for PHP 8, 64 bit, TS


    You can then add this dll file to the PHP ext directory and include in php.ini:

    ; develop can be used always:
    xdebug.mode = develop
    ; enable debug and code coverage when required:
    ; xdebug.mode = coverage,debug,develop
    xdebug.client_port = 9003
    xdebug.start_with_request = yes

  • | 1735 points

    @Pen-y-Fan It's always in a small detail... I should have seen it. Thanks a lot.

    It seems to be loaded:

    It does not show in the menu, and you can not click to load or unload like other extensions.

    Although I see this in Quick Settings:

    Not sure if this is right.

  • | 16270 points

    @DickVG yes, that looks like it's working, check your php.ini to see if there are two lines for Xdebug, maybe one is commented out. You can also click the Web button and you will see a Laragon information page, click info next to the PHP version and you will see phpinfo(), this will also confirm the modules loaded, Xdebug is about halfway down the page.


  • | 1735 points

    @Pen-y-Fan: Thanks for your help. I have exactly the same information on my phpinfo().

    Still no Breakpoints and debugging does not happen. I don't see variables or other information when running the debugger


    Any advice?

  • | 1735 points


    I added a log file. These are my ini settings:


    The problem apparently is mentioned in the log:

    [9560] [Step Debug] WARN: 1970-01-01 00:41:28.989970: There was a problem sending 179 bytes on socket 1264: An existing connection was forcibly closed by the remote host.

  • | 16270 points


    I'm using PhpStorm. I haven't used vs code in a while, so I opened it up.

    See this blog for instructions: Tutorial: Using Xdebugger with PHP & VSCode to Debug

    After installing the Xdebug extension for VS Code


    I set up php.ini:

    xdebug.mode = debug
    xdebug.client_port = 9003
    xdebug.start_with_request = yes

    Then saved the configuration file (click the cog icon) - this was auto-generated:

        // Use IntelliSense to learn about possible attributes.
        // Hover to view descriptions of existing attributes.
        // For more information, visit:
        "version": "0.2.0",
        "configurations": [
                "name": "Listen for Xdebug",
                "type": "php",
                "request": "launch",
                "port": 9003
                "name": "Launch currently open script",
                "type": "php",
                "request": "launch",
                "program": "${file}",
                "cwd": "${fileDirname}",
                "port": 0,
                "runtimeArgs": [
                "env": {
                    "XDEBUG_MODE": "debug,develop",
                    "XDEBUG_CONFIG": "client_port=${port}"
                "name": "Launch Built-in web server",
                "type": "php",
                "request": "launch",
                "runtimeArgs": [
                "program": "",
                "cwd": "${workspaceRoot}",
                "port": 9003,
                "serverReadyAction": {
                    "pattern": "Development Server \\(http://localhost:([0-9]+)\\) started",
                    "uriFormat": "http://localhost:%s",
                    "action": "openExternally"

    I created a simple example.php script

    $message = "Hello, world";
    echo $message;

    Set debug on the echo line and ran the script with debug.


    I hope this helps.

  • | 16270 points

    @DickVG for web requests I used the Xdebug helper extension

    Opened the webpage, in my case http://xdebug-test.local/example.php

    Then enabled the Xdebug extension to debug and set VS Code to listen for Xdebug, refreshed the page and it stopped at the breakpoint:


    1. Set Xdebug extension to Debug
    2. Set VS Code to listen for Xdebug
    3. Set the breakpoint
    4. Refresh the page and view with to VS Code
    5. Note: "Hello, world" was already displayed on the webpage you can see when I refreshed the page the loading icon is "going around", while I was debugging. I had to switch to VS Code (Ctrl + Tab), it didn't automatically focus, although it had detected the Xdebug breakpoint. You can see the local variable is set. Press F8 to step over.

  • | 1735 points

    I still can't get it to work. I think the problem is, that only Xdebug appears in the Quick Settings, but activating the setting will not work, although Apache is reloading. All other extensions can be unloaded and loaded from the menu. Xdebug is added from within Visual Studio as an extension


  • | 1735 points

    Digging somewhat further I read that the command xdebug_break() should stop at the next line in your PHP code.


    But it shows this error while refreshing the Browser page:
    Fatal error: Uncaught Error: Call to undefined function xdebug_break()

    My guess is that although Xdebug is added in Visual Studio as an extension, for some reason it will not load with Laragon and causes those problems.

  • | 16270 points

    @DickVG example of xdebug_break() working:


    My guess is Xdebug hasn't loaded, check your php.ini has Xdebug loaded and debug is enabled:

    xdebug.mode = coverage,debug,develop
    $message = "<h1>Hello, world</h1>";
    $xdebugBreak = xdebug_break();
    echo $message;

    If you have changed PHP version stop and start Laragon, then check the info.


  • | 1735 points

    @Pen-y-Fan I have the same output in the info for Xdebug.

    It might be a problem with the port 9003 (which is also used for MSQL?)

    phi.ini is

    This is the error log.

    [18444] [Step Debug] INFO: Connecting to configured address/port:
    [18444] [Step Debug] INFO: Connected to debugging client: (through xdebug.client_host/xdebug.client_port). :-)
    [18444] [Step Debug] -> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="" fileuri="file:///C:/Laragon/www/Test/home.php" language="PHP" xdebug:language_version="8.0.4RC1" protocol_version="1.0" appid="18444" idekey="VSCODE"><engine version="3.0.4"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[]]></url><copyright><![CDATA[Copyright (c) 2002-2021 by Derick Rethans]]></copyright></init>

    [18444] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="" status="break" reason="ok"><xdebug:message filename="file:///C:/Laragon/www/Test/home.php" lineno="4"></xdebug:message></response>

    [18444] [Step Debug] WARN: 2021-08-01 11:53:43.800208: There was a problem sending 268 bytes on socket 1224: An existing connection was forcibly closed by the remote host.
    [18444] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="" status="stopping" reason="ok"></response>

    [18444] [Step Debug] WARN: 2021-08-01 11:53:43.800401: There was a problem sending 179 bytes on socket 1224: An existing connection was forcibly closed by the remote host.
    [18444] Log closed at 2021-08-01 11:53:43.800478

  • | 16270 points

    @DickVG you can only have one app listening on port 9003, if you have other VS Code tabs open close all debug listeners (click the stop icon)


    You can run netstat (Menu > Tools > netstat) and see if Code, or another app, is listening on port 9003


    You should only see this line when Code is set to listen for Xdebug.

    Try xdebug.client_host=localhost (comment out the line with

    MySQL listens on port 3306. Sometimes I've seen problems with port 9000, which I why I expect it was changed to 9003, if another app is using 9003 either close the other app or change the client_port in php.ini and VS Code config.

  • | 1735 points


    I'm learning a lot thanks to you, but the problem is still not solved.

    I'm on a Windows 10 machine and Netstat does not show Path in Windows apparently, so I looked up the PID and it confirms the CODE.exe for Visual Code.



    I'm still searching to make it work. Any other suggestions?

  • | 1735 points


    I checked the other port for MSQL and APACHE and if NA means Not Available that could be the reason.


  • | 1735 points

    I finally made it work....

    The extension Intelephense interferes with Xdebug apparently. When deactivating Intelephense everything works fine.

    Again thanks for your time and guidance. I learned a lot and you made me search on a lot of information that will be useful for the future.


Log in to reply

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