[xdebug]
zend_extension="/opt/homebrew/opt/xdebug@8.1/xdebug.so"
# 以下新增
xdebug.mode=debug
xdebug.client_host=127.0.0.1
xdebug.client_port="9003"
xdebug.remote_handler=dbgp
;xdebug.start_with_request=yes
xdebug.show_local_vars = 1
CLI Interpreters配置,注意Debugger那里,必須要有Xdebug的信息
注意這里的Port端口與xdebug.client_port
端口號(hào)相對(duì)應(yīng)
vim /etc/hosts
增加條目
127.0.0.1 yoursite.test
2. 終端里
export XDEBUG_SESSION=1
#進(jìn)入項(xiàng)目
php start.php start #啟動(dòng)
ctrl+c
中止
這里把參數(shù)改成 restart,解決重復(fù)啟動(dòng)的問(wèn)題。
正常開發(fā)的時(shí)候按小?? 啟動(dòng)。
需要調(diào)試的時(shí)候,先打開小電話??,然后點(diǎn)擊蟲子按鈕
在瀏覽器里或者curl訪問(wèn)特定的路由
點(diǎn)擊 Stop All
PS:要提醒一點(diǎn),如果打開小電話監(jiān)聽,webman就無(wú)法熱重載了。不需要debug的時(shí)候請(qǐng)關(guān)閉小電話,
至于出現(xiàn)如下的提示:
Xdebug: [Step Debug] Could not connect to debugging client. Tried: 127.0.0.1:9003 (through xdebug.client_host/xdebug.client_port) :-(
只是告訴你,php在啟動(dòng)的時(shí)候要去連接9003的端口,沒有連接上,并不影響正常的開發(fā)。這個(gè)消息在啥時(shí)候需要關(guān)注呢?就是當(dāng)你的小電話打開了,還提示這個(gè)問(wèn)題,你就想思考是不是IP和端口設(shè)置的有問(wèn)題了。
按照你的步驟 啟動(dòng)webman報(bào)錯(cuò)
這不是報(bào)錯(cuò),先打開右上角的??,讓phpstorm去監(jiān)聽9003端口,然后再運(yùn)行php,這樣php啟動(dòng)的時(shí)候就會(huì)去連接9003了。
這只是告訴你,無(wú)法連接那個(gè)9003端口,并不影響開發(fā)。php-cli模式下,貌似在配置xdebug后無(wú)論要不要調(diào)試啟動(dòng)的時(shí)候都會(huì)去連接端口。
你這個(gè)應(yīng)該是本機(jī)調(diào)試環(huán)境 , 我的是webman運(yùn)行在vagrant環(huán)境 然后進(jìn)行端口映射
這是在蘋果系統(tǒng)上配置的過(guò)程,在windows上配置,需要先下載 XDebug xdebug地址下載 然后按照大佬的過(guò)程,進(jìn)行配置完成即可進(jìn)入調(diào)試模式下
注意,啟動(dòng)服務(wù),要執(zhí)行 windows.php 文件即可
我想問(wèn)問(wèn)各位大佬,為什么webman基于workerman 可以使用xdebug調(diào)試,而workerman 的應(yīng)用卻無(wú)法使用 xdebug調(diào)試 呢?難道xdebug3也可以調(diào)試 workerman 了??
GatewayWorker能用嗎,啟動(dòng)的時(shí)候沒報(bào)錯(cuò),連接的時(shí)候報(bào)錯(cuò)了
經(jīng)過(guò)多次測(cè)試,在mac下 在控制器是斷點(diǎn)是斷不下來(lái)的 把執(zhí)行邏輯扔到其他類上就可以了 原因未知
//文件路徑 Controller\IndexController.php
<?php
namespace app\controller;
use app\Controller\Common;
class IndexController {
public function index(Request $request) {
return Common::test();
}
}
}
//Controller\Common.php
<?php
namespace app\controller;
class Common{
public static function pay(Request $request) {
$a=1;//這里下斷點(diǎn)
$b[0]=$a;
$c=$b;
return 0;
}
}
}
windows+phpstorm+xdebug 也沒成功,下面是ini配置
extension = swoole.so
xdebug.mode=debug
xdebug.client_host=host.docker.internal
xdebug.discover_client_host=true
xdebug.start_with_request=yes
xdebug.client_port=9111
xdebug.remote_handler=dbgp
xdebug.idekey=xdebug
贊