[英]Setting up xdebug with ubuntu, php, sublime and vagrant
我有一個在我的 Mac 上本地運行的 vagrant 框以及 PHP 7.4 和 xdebug。 我可以看到 xdebug 加載了:
vagrant@vagrant:~$ php -v
PHP 7.4.28 (cli) (built: Feb 17 2022 16:06:19) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.28, Copyright (c), by Zend Technologies
with Xdebug v3.1.2, Copyright (c) 2002-2021, by Derick Rethans
...和 /etc/php/7.4/mods-available/xdebug.ini 有:
zend_extension = /usr/lib/php/20190902/xdebug.so
xdebug.remote_autostart = 1
xdebug.remote_enable = 1
xdebug.remote_handler = dbgp
xdebug.remote_host = 127.0.0.1
xdebug.remote_log = /tmp/xdebug_remote.log
xdebug.remote_mode = req
xdebug.remote_port = 9000 #if you want to change the port you can change
我的 Sublime Text 3/Packages/User/Xdebug.sublime-settings 有:
...
"host": "127.0.0.1",
// Which port number Sublime Text should listen
// to connect with debugger engine.
"port": 9000,
...
我嘗試將端口 9000 從 vagrant 轉發到主機,但我收到一條錯誤消息,指出該端口已被使用。 我猜這是因為 sublime 在主機端使用它。
我遇到了幾個問題。 首先,我需要 xdebug v.3(不是 2)的 xdebug 配置方法。 此外, client_host
需要設置為 VM 的網關,即10.0.2.2
而不是 127.0.0.1。 您可以使用route -nee
查看您的 VM 的網關
這是我在/etc/php/7.4/mods-available/xdebug.ini
中的設置
zend_extension = /usr/lib/php/20190902/xdebug.so
xdebug.mode=debug
xdebug.start_with_request=yes
xdebug.client_host= 10.0.2.2
xdebug.client_port = 9000
xdebug.log = /var/log/xdebug.log
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.