Skip to content

Update README PHP setup with Xdebug #516

Open
@shadydealer

Description

@shadydealer

I went through the steps of installing xdebug and vdebug to debug my php setup and I couldn't, for the life of me get a debugger session working. I was getting the same error log over and over again:

[60807] Log opened at 2022-10-20 12:14:47.026666
[60807] [Step Debug] DEBUG: Found 'XDEBUG_CONFIG' ENV variable
[60807] [Step Debug] INFO: Connecting to configured address/port: 127.0.0.1:9000.
[60807] [Step Debug] INFO: Connected to debugging client: 127.0.0.1:9000 (through xdebug.client_host/xdebug.client_port). :-)
[60807] [Step Debug] -> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="{some_file_path}" language="PHP" xdebug:language_version="8.1.10" protocol_version="1.0" appid="60807" idekey="xdebug"><engine version="3.1.5"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[https://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2022 by Derick Rethans]]></copyright></init>

[60807] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" status="stopping" reason="ok"></response>

[60807] [Step Debug] WARN: 2022-10-20 12:14:47.028073: There was a problem sending 179 bytes on socket 6: Broken pipe.
[60807] Log closed at 2022-10-20 12:14:47.028225

There were 2 reasons:

  1. The VdebugSetupPHP section includes a helper script to start a debugging session:
#!/bin/bash
export XDEBUG_CONFIG="idekey=xdebug"
/usr/bin/php "$@"

howerver, the xdebug docs also state that XDEBUG_SESSION=1 should be set, otherwise the debug session doesn't seem to start. So the php-xdebug script should be:

#!/bin/bash
export XDEBUG_SESSION=1
export XDEBUG_CONFIG="idekey=xdebug" # found out that this is not really needed
/usr/bin/php "$@"
  1. The VdebugSetupPHP section says that we should set our host_port to 9000, but as stated here (I honestly don't understand the why, yet) that is wrong, and should be on a port different than 9000 (like 9003, the default xdebug port) and in the .vimrc we'd need to add the following lines:
let g:vdebug_options = {}
let g:vdebug_options["port"] = 9003 # same as port defined for xdebug

now, starting a debug session with php-xdebug works as expected :)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions