I am completely new on PHP and Xdebug. I have installed XAMPP on Windows 10 and I have a running application on PHP.
So I wanted to trace the application on Visual Studio Code to understand it, I used the Xdebug. I did the following:
I download the appropriate php-xdebug.dll (according to PHP version, on xdebug.org/wizard) and place it on PHP directory of XAMPP.
I installed the PHP debug extension and added these lines:
xdebug.mode = debug
xdebug.start_with_request = yes
xdebug.client_port = 9000
Add this line to json:
"runtimeExecutable": "C:\\Xampp\\PHP\\php.exe"
Restart the Apache service in XAMPP.
Now I started the application and put some breakpoint to trace the application. It worked fine for about 4 or 5 hours, without any problem. But after that it stop working.
When I put the breakpoint it enters the breakpoint. When I press "press into" button, nothing happens and it seems Xdebug not working.
How can I check what is the problem with Wdebug?
EDIT:
This is what I found. This is a very simple code which I want to trace:
<?php
$a=100;
$b=200;
echo $a."<br/>";
echo $b."<br/>";
echo $a+$b;
If I place in the root of htdocs
, the Xdebug won't work any more, but if I put in a subdirectory inside htdocs
then the debug works fine.
This the result in Xdebug log file:
[8668] Log opened at 2262-04-09 09:08:59.927045
[8668] [Step Debug] INFO: Connecting to configured address/port: localhost:9000.
[8668] [Step Debug] INFO: Connected to debugging client: localhost:9000 (through xdebug.client_host/xdebug.client_port). :-)
[8668] [Step Debug] -> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file:///C:/xampp/htdocs/index.php" language="PHP" xdebug:language_version="7.2.34" protocol_version="1.0" appid="8668"><engine version="3.0.4"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[https://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2021 by Derick Rethans]]></copyright></init>
[8668] [Step Debug] <- breakpoint_list -i 1
[8668] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="1"></response>
[8668] [Step Debug] <- breakpoint_list -i 2
[8668] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="2"></response>
[8668] [Step Debug] <- breakpoint_list -i 3
[8668] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="3"></response>
[8668] [Step Debug] <- breakpoint_list -i 4
[8668] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="4"></response>
[8668] [Step Debug] <- breakpoint_list -i 5
[8668] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="5"></response>
[8668] [Step Debug] <- breakpoint_list -i 6
[8668] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="6"></response>
[8668] [Step Debug] <- breakpoint_set -i 7 -t line -f file:///c:/xampp/htdocs/test/1.php -n 3
[8668] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="7" id="86680001"></response>
[8668] [Step Debug] <- breakpoint_set -i 8 -t line -f file:///c:/xampp/htdocs/1.php -n 3
[8668] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="8" id="86680002"></response>
[8668] [Step Debug] <- breakpoint_set -i 9 -t line -f file:///c:/xampp/htdocs/app/hmi/API/addline.php -n 16
[8668] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="9" id="86680003"></response>
[8668] [Step Debug] <- breakpoint_set -i 10 -t line -f file:///c:/xampp/htdocs/app/hmi/API/addorderstation.php -n 17
[8668] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="10" id="86680004"></response>
[8668] [Step Debug] <- breakpoint_set -i 11 -t line -f file:///c:/xampp/htdocs/app/hmi/API/addstation.php -n 14
[8668] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="11" id="86680005"></response>
[8668] [Step Debug] <- breakpoint_set -i 12 -t line -f file:///c:/xampp/htdocs/index.php -n 3
[8668] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="12" id="86680006"></response>
[8668] [Step Debug] <- breakpoint_set -i 13 -t line -f file:///c:/xampp/htdocs/index.php -n 17
[8668] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="13" id="86680007"></response>
[8668] [Step Debug] <- breakpoint_list -i 14
[8668] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="14"><breakpoint type="line" filename="file:///C:/xampp/htdocs/app/hmi/API/addstation.php" lineno="14" state="enabled" hit_count="0" hit_value="0" id="86680005"></breakpoint><breakpoint type="line" filename="file:///C:/xampp/htdocs/app/hmi/API/addorderstation.php" lineno="17" state="enabled" hit_count="0" hit_value="0" id="86680004"></breakpoint><breakpoint type="line" filena
[8668] [Step Debug] <- breakpoint_list -i 15
[8668] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="15"><breakpoint type="line" filename="file:///C:/xampp/htdocs/app/hmi/API/addstation.php" lineno="14" state="enabled" hit_count="0" hit_value="0" id="86680005"></breakpoint><breakpoint type="line" filename="file:///C:/xampp/htdocs/app/hmi/API/addorderstation.php" lineno="17" state="enabled" hit_count="0" hit_value="0" id="86680004"></breakpoint><breakpoint type="line" filena
[8668] [Step Debug] <- breakpoint_set -i 16 -t exception -x *
[8668] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="16" id="86680008"></response>
[8668] [Step Debug] <- run -i 17
[8668] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="run" transaction_id="17" status="break" reason="ok"><xdebug:message filename="file:///C:/xampp/htdocs/index.php" lineno="3"></xdebug:message></response>
[8668] [Step Debug] <- stack_get -i 18
[8668] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="stack_get" transaction_id="18"><stack where="{main}" level="0" type="file" filename="file:///C:/xampp/htdocs/index.php" lineno="3"></stack></response>
[8668] [Step Debug] <- eval -i 19 -- KCRh
[8668] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="eval" transaction_id="19" status="break" reason="ok"><error code="206"><message><![CDATA[error evaluating code]]></message></error></response>
[8668] [Step Debug] <- eval -i 20 -- Y2hyKCRhKQ==
[8668] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="eval" transaction_id="20"><property type="string" size="1" encoding="base64"><![CDATA[AA==]]></property></response>
[8668] [Step Debug] <- eval -i 21 -- JGE=
[8668] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="eval" transaction_id="21"><property type="null"></property></response>
[8668] [Step Debug] <- eval -i 22 -- JF9SRVFVRVNUWydQQVJBTVMnXQ==
[8668] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="eval" transaction_id="22"><property type="null"></property></response>
[8668] [Step Debug] <- eval -i 23 -- JHBhcmFtcw==
[8668] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="eval" transaction_id="23"><property type="null"></property></response>
[8668] [Step Debug] <- context_names -i 24 -d 0
[8668] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="context_names" transaction_id="24"><context name="Locals" id="0"></context><context name="Superglobals" id="1"></context><context name="User defined constants" id="2"></context></response>
[8668] [Step Debug] <- context_get -i 25 -d 0 -c 0
[8668] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="context_get" transaction_id="25" context="0"><property name="$a" fullname="$a" type="uninitialized"></property><property name="$b" fullname="$b" type="uninitialized"></property></response>
[8668] [Step Debug] <- step_over -i 26
[8668] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="step_over" transaction_id="26" status="stopping" reason="ok"></response>
[8668] [Step Debug] <- stop -i 27
[8668] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="stop" transaction_id="27" status="stopped" reason="ok"></response>
[8668] Log closed at 2262-04-09 09:08:59.927045
The only I could do , I changed the website Folder from htdocs to htdocs/Projects. and everything worked fine after that. I couldn't find the reason