Виртуальный ящик / Ubuntu с xdebug / Phpstorm - PullRequest
0 голосов
/ 14 апреля 2020

Я использую PhpStorm 2019.3.2, XAMPP 7.4.1.1 на Virtual Box Version 6.1.2 r135662 (Qt5.6.2) с Ubuntu 18.04.3 LTS машиной для локальной разработки. Моя версия php / xdebug выглядит следующим образом:

PHP 7.4.1 (cli) (built: Jan 16 2020 14:02:41) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Xdebug v2.9.1, Copyright (c) 2002-2020, by Derick Rethans

Моя конфигурация Xdebug выглядит следующим образом:

[xDebug]
zend_extension = /opt/lampp/lib/php/extensions/no-debug-non-zts-20190902/xdebug.so

xdebug.remote_enable = 1
xdebug.remote_autostart = 1 ; TODO change to '1' later
xdebug.idekey = "PHPSTORM"
xdebug.remote_log = /opt/lampp/temp/xdebug.log
xdebug.remote_host = 127.0.0.1
xdebug.remote_port = 9030
xdebug.profiler_enable = 0

При запуске Xdebug для создания отладочного соединения требуется до 60 секунд, иногда даже дольше.

Мой журнал Xdebug выглядит нормально:

[2432] Log opened at 2020-04-10 20:37:49
[2432] I: Connecting to configured address/port: 127.0.0.1:9030.
[2432] I: Connected to client. :-)
[2432] -> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file:///home/admin/Desktop/wordpress/wp-admin/tools.php" language="PHP" xdebug:language_version="7.4.2" protocol_version="1.0" appid="2432" idekey="PHPSTORM"><engine version="2.9.1"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[https://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2020 by Derick Rethans]]></copyright></init>

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

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

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

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

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

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

[2432] <- stdout -i 7 -c 1
[2432] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="stdout" transaction_id="7" success="1"></response>

[2432] <- status -i 8
[2432] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="status" transaction_id="8" status="starting" reason="ok"></response>

[2432] <- step_into -i 9
[2432] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="step_into" transaction_id="9" status="break" reason="ok"><xdebug:message filename="file:///home/admin/Desktop/wordpress/wp-admin/tools.php" lineno="9"></xdebug:message></response>

[2432] <- eval -i 10 -- aXNzZXQoJF9TRVJWRVJbJ1BIUF9JREVfQ09ORklHJ10p
[2432] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="eval" transaction_id="10"><property type="bool"><![CDATA[0]]></property></response>

[2432] <- eval -i 11 -- aXNzZXQoJF9TRVJWRVJbJ1NFUlZFUl9OQU1FJ10p
[2432] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="eval" transaction_id="11"><property type="bool"><![CDATA[1]]></property></response>

[2432] <- eval -i 12 -- KHN0cmluZykoJF9TRVJWRVJbJ1NFUlZFUl9OQU1FJ10p
[2432] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="eval" transaction_id="12"><property type="string" size="9" encoding="base64"><![CDATA[bG9jYWxob3N0]]></property></response>

[2432] <- eval -i 13 -- KHN0cmluZykoJF9TRVJWRVJbJ1NFUlZFUl9QT1JUJ10p
[2432] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="eval" transaction_id="13"><property type="string" size="2" encoding="base64"><![CDATA[ODA=]]></property></response>

[2432] <- eval -i 14 -- KHN0cmluZykoJF9TRVJWRVJbJ1JFUVVFU1RfVVJJJ10p
[2432] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="eval" transaction_id="14"><property type="string" size="195" encoding="base64"><![CDATA[L3dvcmRwcmVzcy1tYXJrZXRTYWFTL3dwLWFkbWluL3Rvb2xzLnBocD9wYWdlPWNyb250cm9sX2FkbWluX21hbmFnZV9wYWdlJmFjdGlvbj1ydW4tY3JvbiZpZD11cGRhdGVfU2hhcmVhYmxlTmV3c2xldHRlciZzaWc9NDBjZDc1MGJiYTk4NzBmMThhYWRhMjQ3OGIyNDg0MGEmbmV4dF9ydW49MTU4NjU0ODc5MCZfd3Bub25jZT1jZTc4M2I0NDAy]]></property></response>

[2432] <- breakpoint_set -i 15 -t line -f file:///home/admin/Desktop/wordpress/wp-content/plugins/shared-content/includes/Share_Newsletter.php -n 66
[2432] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="15" id="24320001" resolved="unresolved"></response>

[2432] <- stack_get -i 16
[2432] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="stack_get" transaction_id="16"><stack where="{main}" level="0" type="file" filename="file:///home/admin/Desktop/wordpress/wp-admin/tools.php" lineno="9"></stack></response>

[2432] <- run -i 17
[2432] -> <notify xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" name="error"><xdebug:message filename="file:///home/admin/Desktop/wordpress/wp-content/plugins/mailster/classes/ajax.class.php" lineno="245" type="Deprecated"><![CDATA[Unparenthesized `a ? b : c ? d : e` is deprecated. Use either `(a ? b : c) ? d : e` or `a ? b : (c ? d : e)`]]></xdebug:message></notify>

[2432] -> <notify xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" name="error"><xdebug:message filename="file:///home/admin/Desktop/wordpress/wp-content/plugins/thrive-visual-editor/inc/classes/class-tcb-menu-walker.php" lineno="140" type="Warning"><![CDATA[Declaration of TCB_Menu_Walker::walk($elements, $max_depth) should be compatible with Walker::walk($elements, $max_depth, ...$args)]]></xdebug:message></notify>

[2432] -> <notify xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" name="breakpoint_resolved"><breakpoint type="line" resolved="resolved" filename="file:///home/admin/Desktop/wordpress/wp-content/plugins/shared-content/includes/Share_Newsletter.php" lineno="66" state="enabled" hit_count="0" hit_value="0" id="24320001"></breakpoint></notify>

[2432] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="run" transaction_id="17" status="stopping" reason="ok"></response>

[2432] <- run -i 18
[2432] Log closed at 2020-04-10 20:37:58

[2432] Log opened at 2020-04-10 20:37:58
[2432] I: Connecting to configured address/port: 127.0.0.1:9030.
[2432] I: Connected to client. :-)
[2432] -> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file:///home/admin/Desktop/wordpress/wp-admin/tools.php" language="PHP" xdebug:language_version="7.4.2" protocol_version="1.0" appid="2432" idekey="PHPSTORM"><engine version="2.9.1"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[https://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2020 by Derick Rethans]]></copyright></init>

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

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

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

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

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

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

[2432] <- stdout -i 7 -c 1
[2432] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="stdout" transaction_id="7" success="1"></response>

[2432] <- status -i 8
[2432] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="status" transaction_id="8" status="starting" reason="ok"></response>

[2432] <- step_into -i 9
[2432] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="step_into" transaction_id="9" status="break" reason="ok"><xdebug:message filename="file:///home/admin/Desktop/wordpress/wp-admin/tools.php" lineno="9"></xdebug:message></response>

[2432] <- eval -i 10 -- aXNzZXQoJF9TRVJWRVJbJ1BIUF9JREVfQ09ORklHJ10p
[2432] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="eval" transaction_id="10"><property type="bool"><![CDATA[0]]></property></response>

[2432] <- eval -i 11 -- aXNzZXQoJF9TRVJWRVJbJ1NFUlZFUl9OQU1FJ10p
[2432] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="eval" transaction_id="11"><property type="bool"><![CDATA[1]]></property></response>

[2432] <- eval -i 12 -- KHN0cmluZykoJF9TRVJWRVJbJ1NFUlZFUl9OQU1FJ10p
[2432] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="eval" transaction_id="12"><property type="string" size="9" encoding="base64"><![CDATA[bG9jYWxob3N0]]></property></response>

[2432] <- eval -i 13 -- KHN0cmluZykoJF9TRVJWRVJbJ1NFUlZFUl9QT1JUJ10p
[2432] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="eval" transaction_id="13"><property type="string" size="2" encoding="base64"><![CDATA[ODA=]]></property></response>

[2432] <- eval -i 14 -- KHN0cmluZykoJF9TRVJWRVJbJ1JFUVVFU1RfVVJJJ10p
[2432] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="eval" transaction_id="14"><property type="string" size="132" encoding="base64"><![CDATA[L3dvcmRwcmVzcy1tYXJrZXRTYWFTL3dwLWFkbWluL3Rvb2xzLnBocD9wYWdlPWNyb250cm9sX2FkbWluX21hbmFnZV9wYWdlJmNyb250cm9sX21lc3NhZ2U9MSZjcm9udHJvbF9uYW1lPXVwZGF0ZV9TaGFyZWFibGVOZXdzbGV0dGVy]]></property></response>

[2432] <- breakpoint_set -i 15 -t line -f file:///home/admin/Desktop/wordpress/wp-content/plugins/shared-content/includes/Share_Newsletter.php -n 66
[2432] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="15" id="24320002" resolved="unresolved"></response>

[2432] <- stack_get -i 16
[2432] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="stack_get" transaction_id="16"><stack where="{main}" level="0" type="file" filename="file:///home/admin/Desktop/wordpress/wp-admin/tools.php" lineno="9"></stack></response>

[2432] <- run -i 17
[2432] -> <notify xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" name="error"><xdebug:message filename="file:///home/admin/Desktop/wordpress/wp-content/plugins/mailster/classes/ajax.class.php" lineno="245" type="Deprecated"><![CDATA[Unparenthesized `a ? b : c ? d : e` is deprecated. Use either `(a ? b : c) ? d : e` or `a ? b : (c ? d : e)`]]></xdebug:message></notify>

[2432] -> <notify xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" name="error"><xdebug:message filename="file:///home/admin/Desktop/wordpress/wp-content/plugins/thrive-visual-editor/inc/classes/class-tcb-menu-walker.php" lineno="140" type="Warning"><![CDATA[Declaration of TCB_Menu_Walker::walk($elements, $max_depth) should be compatible with Walker::walk($elements, $max_depth, ...$args)]]></xdebug:message></notify>

[2432] -> <notify xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" name="breakpoint_resolved"><breakpoint type="line" resolved="resolved" filename="file:///home/admin/Desktop/wordpress/wp-content/plugins/shared-content/includes/Share_Newsletter.php" lineno="66" state="enabled" hit_count="0" hit_value="0" id="24320002"></breakpoint></notify>

[2432] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="run" transaction_id="17" status="stopping" reason="ok"></response>

[2432] <- run -i 18
[2432] Log closed at 2020-04-10 20:38:14

Я подозреваю, что может быть проблема с межсетевым экраном между виртуальным ящиком и windows 10 (моя хост-система).

Мои настройки сети VirtualBox выглядят следующим образом, так как у меня включено два адаптера:

enter image description here

enter image description here

Я попытался изменить мои xdebug -установки следующим образом, используя свой Host`s-IP:

[xDebug]
zend_extension = /opt/lampp/lib/php/extensions/no-debug-non-zts-20190902/xdebug.so

xdebug.remote_enable = 1
xdebug.remote_autostart = 1 ; TODO change to '1' later
xdebug.idekey = "PHPSTORM"
xdebug.remote_log = /opt/lampp/temp/xdebug.log
xdebug.remote_host = 192.168.56.1
xdebug.remote_port = 9030
xdebug.profiler_enable = 0

Однако тогда я получаю:

[8323] Log opened at 2020-04-13 21:42:20
[8323] I: Connecting to configured address/port: 192.168.56.1:9030.
[8323] E: Time-out connecting to client (Waited: 200 ms). :-(
[8323] Log closed at 2020-04-13 21:42:20

Любые предложения что я делаю не так? Есть ли какие-либо конкретные параметры c xdebug или virutalbox, которые мне нужно изменить?

Я ценю ваши ответы!

ОБНОВЛЕНИЕ

Мой пинг до мой хост IP работает:

admin@php-VirtualBox:~$ ping -c 4 192.168.56.1
PING 192.168.56.1 (192.168.56.1) 56(84) bytes of data.
64 bytes from 192.168.56.1: icmp_seq=1 ttl=128 time=0.492 ms
64 bytes from 192.168.56.1: icmp_seq=2 ttl=128 time=0.444 ms
64 bytes from 192.168.56.1: icmp_seq=3 ttl=128 time=0.381 ms
64 bytes from 192.168.56.1: icmp_seq=4 ttl=128 time=0.562 ms

--- 192.168.56.1 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3056ms
rtt min/avg/max/mdev = 0.381/0.469/0.562/0.071 ms
...