詳解關(guān)于php的xdebug配置(編輯器vscode)
雖然說echo和print_r是公認(rèn)的最實(shí)用的調(diào)試工具,但是效率真的沒有可視化的直接斷點(diǎn)那么高。這里簡單介紹如果安裝及配置xdebug for vscode
一、PHP環(huán)境處的配置
1、編譯安裝
下載及編譯php,因?yàn)槲宜诘墓緋hp版本是5.4的,所以去xdebug官網(wǎng)上選了相對比較底的版本.您也可以根據(jù)你們的實(shí)際情況下載相應(yīng)的xdebug版本:https://xdebug.org/download.php
wget https://xdebug.org/files/xdebug-2.4.1.tgz tar -xvf xdebug-2.4.1.tgz cd xdebug-2.4.1/ phpize ./configure make install
make最終結(jié)束輸出:
make install最終結(jié)束輸出:
2、配置php.ini文件
這個是我的配置。為了使得可配性更強(qiáng)。我將xdebug配置寫到:/etc/php.d/xdebug.ini
[Xdebug] zend_extension="/usr/lib64/php/modules/xdebug.so" #這里改成你在make install后的路徑。 xdebug.remote_enable = true xdebug.remote_host = 10.0.5.176 #改成你的vscode所以機(jī)器的ip地址 #default port 9000 xdebug.remote_port = 9000 #如果9000端口沖突了,可以換一個。不過相應(yīng)的vscode配置也要相應(yīng)的改變 xdebug.profiler_enable = on xdebug.auto_trace = On xdebug.show_exception_trace = On xdebug.remote_autostart = On xdebug.collect_vars = On xdebug.collect_return = On xdebug.remote_handler =dbgp xdebug.max_nesting_level = 10000 xdebug.trace_output_dir = "D:/code/videochat" #我這里寫的是php代碼所在的路徑
二、配置vscode
1、使用vscode打開php工程后。安裝php-debug及生成調(diào)試配置文件,如圖所示,依次點(diǎn)擊這些按鈕
2、如下操作后,會出現(xiàn)如下選項(xiàng)框。選中php即可
3、選中后,會出現(xiàn)一個json的配置文件
修改此json文件,注意serverSourceRoot改成你服務(wù)器上,php所在的路徑。不然即使斷下來后,會出現(xiàn)找不到文件的異常
{ // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "name": "Listen for XDebug", "type": "php", "request": "launch", "port": 9000, "stopOnEntry":false, "localSourceRoot": "${workspaceRoot}", "serverSourceRoot": "/work/videochat" }, { "name": "Launch currently open script", "type": "php", "request": "launch", "program": "${file}", "cwd": "${fileDirname}", "port": 9000 } ] }
最后,在vscode里斷點(diǎn)好后。按F5,等待請求,即可享受圖形化的調(diào)試樂趣
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- Sublime里直接運(yùn)行PHP配置方法
- PHPStorm+Xdebug進(jìn)行emote Debug時無法進(jìn)入斷點(diǎn)問題排查
- PhpStorm2020 + phpstudyV8 +XDebug的教程詳解
- PhpStorm配置Xdebug調(diào)試的方法步驟
- Phpstorm+Xdebug斷點(diǎn)調(diào)試PHP的方法
- Mac系統(tǒng)下安裝PHP Xdebug
- 使用PHPStorm+XDebug搭建單步調(diào)試環(huán)境
- PHP 7安裝調(diào)試工具Xdebug擴(kuò)展的方法教程
- PHP調(diào)試及性能分析工具Xdebug詳解
- PHPStorm+XDebug進(jìn)行調(diào)試圖文教程
- 圖文詳解phpstorm配置Xdebug進(jìn)行調(diào)試PHP教程
- 使用phpstorm和xdebug實(shí)現(xiàn)遠(yuǎn)程調(diào)試的方法
- 如何使用SublimeText3配置 PHP IDE環(huán)境
相關(guān)文章
windows7下安裝php的php-ssh2擴(kuò)展教程
這篇文章主要介紹了windows7下安裝php的php-ssh2擴(kuò)展教程,本文同時適用XP系統(tǒng),但Win8沒有測試過,需要的朋友可以參考下2014-07-07PHP實(shí)現(xiàn)微信小程序在線支付功能(代碼實(shí)例)
這篇文章主要介紹了PHP微信小程序在線支付功能(代碼實(shí)例),本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對大家的工作或?qū)W習(xí)具有一定的參考借鑒價值,需要的朋友可以參考下2020-03-03php 實(shí)現(xiàn)銀聯(lián)商務(wù)H5支付的示例代碼
這篇文章主要介紹了php 實(shí)現(xiàn)銀聯(lián)商務(wù)H5支付的示例代碼,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-10-10