Соединение Xdebug было сброшено в XAMPP

#php #visual-studio-code #magento #xampp #xdebug

Вопрос:

Я пытаюсь заставить Xdebug работать в VSCode в Windows. Я только что установил фреймворк Magento 2 в его собственном каталоге xampp/htdocs/magento .

Xdebug отлично работает в /dashboard каталоге, но это все. Если я попытаюсь прослушать Xdebug в любом другом каталоге, точка останова не будет достигнута, и браузер отобразит следующую ошибку:

«До этого места невозможно добраться. Соединение было сброшено.’

Я много часов искал решение, но мне не удалось заставить его работать.

Это соответствующая конфигурация launch.json для VSCode:

     "version": "0.2.0",
    "configurations": [
        
        {
            "name": "Listen for Xdebug",
            "type": "php",
            "request": "launch",
            "port": 9003,
            "runtimeExecutable": "c:\xampp\php\php.exe"
        }
 

Это соответствующая конфигурация php.ini:

 xdebug.mode = debug
xdebug.start_with_request = yes
zend_extension = "C:xamppphpextphp_xdebug.dll"
xdebug.client_host=localhost
xdebug.idekey = VSCODE
xdebug.log="C:xamppphpextxdebug.log"
 

В журнале Xdebug ошибок не отображается, вот последняя запись:

 [14196] Log opened at 2021-10-14 12:35:22.508436
[14196] [Step Debug] INFO: Connecting to configured address/port: localhost:9003.
[14196] [Step Debug] INFO: Connected to debugging client: localhost:9003 (through xdebug.client_host/xdebug.client_port). :-)
[14196] [Step Debug] -> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file:///C:/xampp/htdocs/magento/index.php" language="PHP" xdebug:language_version="7.3.31" protocol_version="1.0" appid="14196" idekey="VSCODE"><engine version="3.1.0"><![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>

[14196] [Step Debug] <- feature_set -i 1 -n resolved_breakpoints -v 1
[14196] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="1" feature="resolved_breakpoints" success="1"></response>

[14196] [Step Debug] <- feature_set -i 2 -n notify_ok -v 1
[14196] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="2" feature="notify_ok" success="1"></response>

[14196] [Step Debug] <- feature_set -i 3 -n extended_properties -v 1
[14196] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="3" feature="extended_properties" success="1"></response>

[14196] [Step Debug] <- breakpoint_set -i 4 -t line -f file:///c:/xampp/htdocs/magento/app/code/Iksula/Appapi/Model/Home/Home.php -n 450
[14196] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="4" id="141960001" resolved="unresolved"></response>

[14196] [Step Debug] <- breakpoint_set -i 5 -t line -f file:///c:/xampp/htdocs/dashboard/index.php -n 3
[14196] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="5" id="141960002" resolved="unresolved"></response>

[14196] [Step Debug] <- run -i 6
 

Кроме того, в /apache/logs/error.log этом нет ничего, что я мог бы заметить неправильно

 [Thu Oct 14 14:35:22.145361 2021] [core:notice] [pid 32252:tid 600] AH00094: Command line: 'c:\xampp\apache\bin\httpd.exe -d C:/xampp/apache'
[Thu Oct 14 14:35:22.147277 2021] [mpm_winnt:notice] [pid 32252:tid 600] AH00418: Parent: Created child process 31772
[Thu Oct 14 14:35:22.501540 2021] [mpm_winnt:notice] [pid 31772:tid 656] AH00354: Child: Starting 150 worker threads.
[Thu Oct 14 14:35:23.239695 2021] [mpm_winnt:notice] [pid 32252:tid 600] AH00428: Parent: child process 31772 exited with status 3221225477 -- Restarting.
[Thu Oct 14 14:35:23.309464 2021] [mpm_winnt:notice] [pid 32252:tid 600] AH00455: Apache/2.4.51 (Win64) OpenSSL/1.1.1l PHP/7.3.31 configured -- resuming normal operations
[Thu Oct 14 14:35:23.309464 2021] [mpm_winnt:notice] [pid 32252:tid 600] AH00456: Apache Lounge VC15 Server built: Oct  8 2021 10:03:59
[Thu Oct 14 14:35:23.309464 2021] [core:notice] [pid 32252:tid 600] AH00094: Command line: 'c:\xampp\apache\bin\httpd.exe -d C:/xampp/apache'
[Thu Oct 14 14:35:23.312450 2021] [mpm_winnt:notice] [pid 32252:tid 600] AH00418: Parent: Created child process 29828
[Thu Oct 14 14:35:23.682622 2021] [mpm_winnt:notice] [pid 29828:tid 660] AH00354: Child: Starting 150 worker threads.
 

Маловероятно, что в конфигурации что-то не так, так как мои точки останова ДЕЙСТВИТЕЛЬНО попадают внутрь /dashboard/index.php , и страница загружается соответствующим образом, однако, если я это сделаю /magento/index.php , страница даже не загрузится.

Есть ли что-нибудь, чего мне не хватает?

Комментарии:

1. Похоже, что в последних сборках Xdebug v3.1.0 TS возникают проблемы с Windows (Apache из XAMPP использует сборки TS PHP). Попробуйте понизить Xdebug до предыдущей версии: 3.0.4. Работает ли это сейчас?

2. FWIW, теперь выпущен Xdebug 3.1.1, который также должен устранить эту проблему.

3. Обновление библиотеки DLL до версии 3.1.1 устранило проблему, спасибо!