用到的工具:phpstudy + vscode
vscode設(shè)置為中文方法:
1.shift + ctrl + p 打開夹囚,搜索configure language
2.修改loocale的值為:zh-CN纵刘,保存
3.shift + ctrl + x 或者點擊下圖,打開插件商店
4.搜索chinese 安裝中文簡體
5.重啟就完成設(shè)置為中文
設(shè)置vscode斷點調(diào)試php
1.在vscode當(dāng)中shitf + ctrl + x打開插件商店
2.搜索php debug進行安裝
3.在php當(dāng)中配置XDebug擴展參數(shù)如下:
[XDebug]
# xdebug擴展的位置荸哟,phpstudy已經(jīng)默認(rèn)設(shè)置好
zend_extension="php安裝目錄\php_xdebug.dll"
xdebug.auto_trace=1
xdebug.collect_params=1
xdebug.collect_return=1
xdebug.trace_output_dir ="D\phpStudy\tmp\xdebug"
xdebug.profiler_output_dir ="D:\phpStudy\tmp\xdebug"
xdebug.profiler_output_name = "cachegrind.out.%t.%p"
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_handler = "dbgp"
xdebug.remote_host = "127.0.0.1"
# 設(shè)置端口號假哎,默認(rèn)是9000,此處因為本地環(huán)境端口沖突故設(shè)置為9001(在vscode配置中需要用到)
xdebug.remote_port = 9001
# 這是用于phpstorm中xdebug調(diào)試的配置鞍历,在vscode中沒有用到
xdebug.idekey = phpstorm
4.下載php xdebug 擴展:https://xdebug.org/download.php舵抹,點擊:custom
installation instructions. 把phpinfo的信息粘貼在編輯框里面后點擊 Analyse my phpinfo() output 按鈕,就會幫你把匹配php版本的擴展分析出來(或者打開網(wǎng)站https://xdebug.org/wizard.php進行分析)
5.檢查phpinfo里面是否有xdebug擴展劣砍,如果有證明已經(jīng)成功開啟xdebug擴展
6.vscode設(shè)置php可執(zhí)行文件:文件--首選項--設(shè)置??? 搜索:php.validate.executablePath?? 在settings.json中編輯?? 添加選項:"php.validate.executablePath": "D:\\phpStudy\\PHPTutorial\\php\\php-7.2.1-nts\\php.exe"(php可執(zhí)行文件完整目錄)
7.打開一個php工程文件夾惧蛹,點擊vscode中的甲殼蟲 并 添加配置 如下圖
8.選擇php,配置甲殼蟲監(jiān)聽端口為9001(前面配置php xdebug的端口),如下圖
9.配置完畢刑枝,重啟apache香嗓,在需要斷點的地方f9左邊看到小紅點就表示那個地方下了斷點
10.f5啟動甲殼蟲堅挺端口,在瀏覽器當(dāng)中訪問下斷點的文件就可以在vscode當(dāng)中斷下來調(diào)試了