phpstorm 調試_PhpStorm中的多用戶調試

phpstorm 調試

by Ray Naldo

雷·納爾多(Ray Naldo)

PhpStorm中的多用戶調試 (Multi-User Debugging in PhpStorm)

使用Xdebug和DBGp代理 (Using Xdebug and DBGp Proxy)

“Er, wait a minute… Don’t you just use xdebug.remote_connect_back which has been introduced since Xdebug 2.1?"

“嗯,請稍等...您不只是使用Xdebug 2.1之后引入的xdebug.remote_connect_back嗎?”

Sure if the web server is only accessible by the developers (e.g. private development server), and if it’s not running behind a NATted firewall, and if you want this guide to end here. See those IFs? Personally, I don’t like IF in programming or in life. So this guide will take the longer way which doesn’t need an IF to start (or at least fewer IFs), that is by using Xdebug’s DBGp proxy.

確保Web服務器僅可由開發人員訪問(例如,私有開發服務器),并且它不在NATted防火墻后面運行,以及是否希望本指南在此處結束。 看到那些IF嗎? 就個人而言,我在編程或生活中都不喜歡IF。 因此,本指南將采用更長的方式,即不需要使用IF(或者至少需要更少的IF)來啟動,即使用Xdebug的DBGp代理。

When a proxy is used, the PHP Xdebug extension no longer connects to PhpStorm directly, but instead connects to the DBGp proxy server. All developers in the team, in turn, then connect to that proxy. Each developer has a separate debugging session running over this proxy, which makes it possible to do multi-user debugging of the same code on the same server.

使用代理時,PHP Xdebug擴展不再直接連接到PhpStorm,而是連接到DBGp代理服務器。 然后,團隊中的所有開發人員都將連接到該代理。 每個開發人員都在此代理上運行單獨的調試會話,這使得可以對同一服務器上的相同代碼進行多用戶調試。

So, with DBGp proxy you can limit who can connect to the proxy, and you may have multiple developers debugging the same web server running behind a NATted firewall.

因此,使用DBGp代理,您可以限制誰可以連接到代理,并且可能有多個開發人員調試在NATted防火墻后運行的同一Web服務器。

Running a DBGp proxy also allows you to avoid NAT issues where (as seen from PHP+Xdebug on the server) all connections seem to come from the same IP (because your internal network is NATted). In this case, you can simply run the dbgp proxy on your NAT machine, configure xdebug.remote_host setting to the IP address of your NAT machine, and configure the IDEs to connect to the proxy running at <NAT-machine>;:9001.

運行DBGp代理還可以避免NAT問題(如從服務器上PHP + Xdebug看到的),所有連接似乎都來自同一IP(因為您的內部網絡已被NAT)。 在這種情況下,您只需在NAT計算機上運行dbgp代理,將xdebug.remote_host設置配置為NAT計算機的IP地址,然后將IDE配置為連接到運行在<NAT-machine>上的代理; :9001。

— https://derickrethans.nl/debugging-with-multiple-users.html

— https://derickrethans.nl/debugging-with-multiple-users.html

建立 (Setup)

Mappings between the project folders and the folders on the server should be done correctly in PhpStorm first for debugging to work.

應該首先在PhpStorm中正確完成項目文件夾和服務器上的文件夾之間的映射,然后才能進行調試。

設置Web服務器 (Setup Web Server)

Although this guide assumes the web server is running on Linux, the guide could also be used on non-Linux web servers with slight modifications.

盡管本指南假定Web服務器在Linux上運行,但該指南也可以在非Linux Web服務器上使用,并稍加修改。

1. Install Xdebug.

1.安裝Xdebug。

# PHP 7+pecl install xdebug  # PHP 5.6.xpecl install xdebug-2.5.5

2. Enable Xdebug extension, then add the following Xdebug configuration to php.ini:

2.啟用Xdebug擴展,然后將以下Xdebug配置添加到php.ini:

[xdebug]zend_extension="<full_path_to_xdebug.so>"
; debugger settingsxdebug.remote_enable=1xdebug.remote_host=127.0.0.1xdebug.remote_port=9000

For this guide, DBGp proxy will run on the same machine as the web server and will use Xdebug’s default port, hence 127.0.0.1:9000.

對于本指南,DBGp代理將與Web服務器在同一臺計算機上運行,??并將使用Xdebug的默認端口,即127.0.0.1:9000

3. Download and install DBGp proxy for remote debugging from Komodo Remote Debugging Package, specifically for your web server’s operating system. This guide will be using 64-bit Linux and PHP Remote Debugging client v11.1.0. Extract the archive; for simplicity I extract all the contents to my home directory i.e. /home/ray/.

3.從Komodo Remote Debugging Package中下載并安裝DBGp代理,以進行遠程調試,特別是針對Web服務器的操作系統。 本指南將使用64位Linux和PHP遠程調試客戶端v11.1.0。 提取檔案; 為簡單起見,我將所有內容提取到我的主目錄(即/home/ray/

4. Run DBGp proxy by executing pydbgpproxy file with parameters:

4.通過執行帶有參數的pydbgpproxy文件來運行DBGp代理:

  • -d <ip_address:port> to set IP address and port of the machine which will be receiving debugger connection from the web server

    -d <ip_address:po rt>設置將要從Web服務器接收調試器連接的計算機的IP地址和端口

  • -i <ip_address:port> to set IP address and port of the machine which will be receiving debugging connection from developer computer

    -i <ip_address:po rt>設置將要從開發人員計算機接收調試連接的計算機的IP地址和端口

In this guide, web server and DBGp proxy will be run on the same machine. If the IP address is 10.211.1.32 and we want to run the proxy on port 9001 then the command will be:

在本指南中,Web服務器和DBGp代理將在同一臺計算機上運行。 如果IP地址為10.211.1.32并且我們想在端口9001上運行代理,則命令將為:

pydbgpproxy -d 127.0.0.1:9000 -i 10.211.1.32:9001

For convenience we could use this script, saved as start-dbgp-proxy.sh.I placed it on the same directory as pydbgpproxy i.e. /home/ray/start-dbgp-proxy.sh) :

為方便起見,我們可以使用這個腳本,保存為start-dbgp-proxy.sh 。我把它放在同一個目錄中pydbgpproxy/home/ray/start-dbgp-proxy.sh ):

ip=$(hostname -I | awk '{$1=$1};1')pydbgpproxy -d 127.0.0.1:9000 -i $ip:9001

5. Make sure to allow connection from localhost on port 9000, and from developer machines on port 9001.

5.確保允許從端口9000上的localhost和端口9001上的開發人員機器進行連接。

6. Run start-dbgp-proxy.sh. Add execute file permission if you can't run it.

6.運行start-dbgp-proxy.sh 。 添加執行文件權限(如果無法運行)。

start-dbgp-proxy.sh

Make sure it can be run without a problem.

確保它可以正常運行。

INFO: dbgp.proxy: starting proxy listeners.  appid: 30430INFO: dbgp.proxy:     dbgp listener on 127.0.0.1:9000INFO: dbgp.proxy:     IDE listener on  10.211.1.32:9001

7. (Optional) Auto-start start-dbgp-proxy.sh on each machine startup by using crontab.

7.(可選)使用crontab在每次啟動計算機時自動啟動start-dbgp-proxy.sh

Edit crontab:

編輯crontab:

crontab -e

Add cron job to auto-start start-dbgp-proxy.sh on each startup:

在每次啟動時將cron作業添加到自動啟動start-dbgp-proxy.sh

@reboot /home/ray/start-dbgp-proxy.sh

設置客戶端 (Setup Client)

1. Access menu Tools > DBGp Proxy > Register IDE on PhpStorm.

1.在PhpStorm上訪問菜單Tools > DBGp Proxy > Regist IDE。

2. Fill IDE key with unique string between developers. FillHost andPort with DBGp proxy's IP address and port (parameter -i on Setup Server #4).

2.用開發人員之間的唯一字符串填充IDE key 。 用DBGp代理的IP地址和端口(在Setup Server#4上的參數-i )填充HostPort

3. Click OK. You should see a success notification popup. If you don’t see it, re-register IDE via Tools > DBGp Proxy > Register IDE. If it's failed or you want to change the configuration, do it via Tools > DBGp Proxy > Configuration...

3.單擊確定。 您應該看到一個成功通知彈出窗口。 如果看不到,請通過Tools > DBGp Proxy > Regist IDE重新注冊IDE。 如果失敗或要更改配置,請不要t via Tools > DBGp Proxy > Conf配置” ...

4. (Optional) If you want to initiate debugging connection from the web browser, it’s recommended to install a debugging extension on your browser: Xdebug Helper Firefox or Xdebug Helper Chrome. Then configure your Xdebug Helper.

4.(可選)如果要通過Web瀏覽器啟動調試連接,建議在瀏覽器上安裝調試擴展程序: Xdebug Helper Firefox或Xdebug Helper Chrome 。 然后配置您的Xdebug助手。

On Firefox, right click Xdebug Helper icon > Manage Extension… > Options On Chrome, right click Xdebug Helper icon > Options

在Firefox上,右鍵單擊Xdebug Helper圖標>管理擴展…>選項在Chrome上,右鍵單擊Xdebug Helper圖標>選項

Fill and save IDE key with the same unique string as when you're registering the IDE (Step #2).

使用與注冊IDE時相同的唯一字符串填充并保存IDE key ( 第2步 )。

開始調試 (Start Debugging)

1. Set breakpoint(s) on PhpStorm.

1.在PhpStorm上設置斷點。

2. Start listening to debug connection in PhpStorm by clicking the ‘phone’ button on the upper right toolbar or from menu Run > Start Listening for PHP Debug Connections. This will enable PhpStorm to react and opens the Debug window automatically when a debugging session is started.

2.單擊右上方工具欄上的“電話”按鈕,或從菜單中的Run > Start Listening for PHP Debug Connecti PhpStorm中的Run > Start Listening for PHP Debug Connecti 。 啟動調試會話時,這將使PhpStorm作出React并自動打開“調試”窗口。

3. Activate Xdebug’s debugger when doing a request. According to Xdebug Documentation there’re 3 ways to do this. But IMHO, the best way which works for all kinds of HTTP methods is by setting a cookie named XDEBUG_SESSION with value <IDE_key> which is the same unique string when we register our IDE to DBGp proxy (Setup Client #2).

3.在執行請求時激活Xdebug的調試器。 根據Xdebug文檔,有3種方法可以做到這一點。 但是恕我直言,適用于所有HTTP方法的最佳方法是設置一個名為XDEBUG_SESSION的cookie,其值為<IDE_k ey>,當我們將IDE注冊到DBGp poxy (安裝程序 #2)時,該cookie是相同的唯一字符串。

  • In the web browser, the cookie will be set automatically by Xdebug Helper extension

    在Web瀏覽器中,將通過Xdebug Helper擴展自動設置cookie。
  • In Postman, the cookie can be set in Request Headers

    在郵遞員中,可以在“請求標題”中設置Cookie

4. Run the script with the cookie already set.

4.在已設置cookie的情況下運行腳本。

5. On success, PhpStorm will show the Debug window automatically.

5.成功后,PhpStorm將自動顯示“調試”窗口。

6. Make sure to unset/don’t send the cookie to disable debug and stop listening debug connection in PhpStorm if you’re not doing any debugging. If you fail to do so, it will make the DBGp proxy hang when there’s too many hanging connections.

6.如果您不進行任何調試,請確保取消設置/不發送cookie來禁用調試并停止監聽PhpStorm中的調試連接。 如果您這樣做失敗,則當掛起的連接過多時,它將使DBGp代理掛起。

Hope this guide works for you.

希望本指南對您有用。

Thank you for reading!

感謝您的閱讀!

參考文獻 (References)

  • https://www.jetbrains.com/help/phpstorm/multiuser-debugging-via-xdebug-proxies.html

    https://www.jetbrains.com/help/phpstorm/multiuser-debugging-via-xdebug-proxies.html

  • https://www.jetbrains.com/help/phpstorm/browser-debugging-extensions.html

    https://www.jetbrains.com/help/phpstorm/browser-debugging-extensions.html

  • https://xdebug.org/docs/remote#starting

    https://xdebug.org/docs/remote#starting

翻譯自: https://www.freecodecamp.org/news/multi-user-debugging-in-phpstorm-75ef628ed50f/

phpstorm 調試

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/391608.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/391608.shtml
英文地址,請注明出處:http://en.pswp.cn/news/391608.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

Tableau Desktop認證:為什么要關心以及如何通過

Woah, Tableau!哇&#xff0c;Tableau&#xff01; By now, almost everyone’s heard of the data visualization software that brought visual analytics to the public. Its intuitive drag and drop interface makes connecting to data, creating graphs, and sharing d…

約束布局constraint-layout導入失敗的解決方案 - 轉

今天有同事用到了約束布局&#xff0c;但是導入我的工程出現錯誤 **提示錯誤&#xff1a; Could not find com.Android.support.constraint:constraint-layout:1.0.0-alpha3** 我網上查了一下資料&#xff0c;都說是因為我的androidStudio版本是最新的穩定版導入這個包就會報這…

算法復習:冒泡排序

思想&#xff1a;對于一個列表,每個數都是一個"氣泡 "&#xff0c;數字越大表示"越重 "&#xff0c;最重的氣泡移動到列表最后一位&#xff0c;冒泡排序后的結果就是“氣泡”按照它們的重量依次移動到列表中它們相應的位置。 算法&#xff1a;搜索整個列表…

leetcode 59. 螺旋矩陣 II(遞歸)

給你一個正整數 n &#xff0c;生成一個包含 1 到 n2 所有元素&#xff0c;且元素按順時針順序螺旋排列的 n x n 正方形矩陣 matrix 。 示例 1&#xff1a; 輸入&#xff1a;n 3 輸出&#xff1a;[[1,2,3],[8,9,4],[7,6,5]] 解題思路 按層進行數字的填充&#xff0c;每一層…

前端基礎進階(七):函數與函數式編程

縱觀JavaScript中所有必須需要掌握的重點知識中&#xff0c;函數是我們在初學的時候最容易忽視的一個知識點。在學習的過程中&#xff0c;可能會有很多人、很多文章告訴你面向對象很重要&#xff0c;原型很重要&#xff0c;可是卻很少有人告訴你&#xff0c;面向對象中所有的重…

期權數據 獲取_我如何免費獲得期權數據

期權數據 獲取by Harry Sauers哈里紹爾斯(Harry Sauers) 我如何免費獲得期權數據 (How I get options data for free) 網頁抓取金融簡介 (An introduction to web scraping for finance) Ever wished you could access historical options data, but got blocked by a paywall…

顯示與刪除使用工具

右擊工具菜單欄中的空白處選擇自定義 在彈出的自定義菜單中選擇命令選項在選擇想要往里面添加工具的菜單&#xff0c;之后在選擇要添加的工具 若想要刪除工具欄中的某個工具&#xff0c;在打開自定義菜單后&#xff0c;按住鼠標左鍵拖動要刪除工具到空白處 例如 轉載于:https:/…

js值的拷貝和值的引用_到達P值的底部:直觀的解釋

js值的拷貝和值的引用介紹 (Introduction) Welcome to this lesson on calculating p-values.歡迎參加有關計算p值的課程。 Before we jump into how to calculate a p-value, it’s important to think about what the p-value is really for.在我們開始計算p值之前&#xff…

leetcode 115. 不同的子序列(dp)

給定一個字符串 s 和一個字符串 t &#xff0c;計算在 s 的子序列中 t 出現的個數。 字符串的一個 子序列 是指&#xff0c;通過刪除一些&#xff08;也可以不刪除&#xff09;字符且不干擾剩余字符相對位置所組成的新字符串。&#xff08;例如&#xff0c;“ACE” 是 “ABCDE…

監督學習-KNN最鄰近分類算法

分類&#xff08;Classification&#xff09;指的是從數據中選出已經分好類的訓練集&#xff0c;在該訓練集上運用數據挖掘分類的技術建立分類模型&#xff0c;從而對沒有分類的數據進行分類的分析方法。 分類問題的應用場景&#xff1a;用于將事物打上一個標簽&#xff0c;通常…

istio 和 kong_如何啟動和運行Istio

istio 和 kongby Chris Cooney克里斯庫尼(Chris Cooney) 如何啟動和運行Istio (How to get Istio up and running) 而一旦完成&#xff0c;您就可以做的瘋狂的事情。 (And the crazy stuff you can do once it is.) The moment you get Istio working on your cluster, it fee…

js練習--貪吃蛇(轉)

最近一直在看javascript&#xff0c;但是發現不了動力。就開始想找動力&#xff0c;于是在網上找到了一個用js寫的貪吃蛇游戲。奈何還不會用git&#xff0c;就只能先這樣保存著。哈哈哈&#xff0c;這也算第一篇博客了&#xff0c;以后會堅持用自己的代碼寫博客的&#xff0c;下…

bzoj千題計劃169:bzoj2463: [中山市選2009]誰能贏呢?

http://www.lydsy.com/JudgeOnline/problem.php?id2463 n為偶數時&#xff0c;一定可以被若干個1*2 矩形覆蓋 先手每次從矩形的一端走向另一端&#xff0c;后手每次走向一個新的矩形 所以先手必勝 n為奇數時&#xff0c;先手走完一步后&#xff0c;剩下同n為偶數 所以先手必敗…

無監督學習-主成分分析和聚類分析

聚類分析&#xff08;cluster analysis&#xff09;是將一組研究對象分為相對同質的群組&#xff08;clusters&#xff09;的統計分析技術&#xff0c;即將觀測對象的群體按照相似性和相異性進行不同群組的劃分&#xff0c;劃分后每個群組內部各對象相似度很高&#xff0c;而不…

struts實現分頁_在TensorFlow中實現點Struts

struts實現分頁If you want to get started on 3D Object Detection and more specifically on Point Pillars, I have a series of posts written on it just for that purpose. Here’s the link. Also, going through the Point Pillars paper directly will be really help…

封裝jQuery下載文件組件

使用jQuery導出文檔文件 jQuery添加download組件 jQuery.download function(url, data, method){if( url && data ){data typeof data string ? data : paramEdit(data);     function paramEdit(obj){        var temStr "",tempStr"…

7.13. parallel - build and execute shell command lines from standard input in parallel

并行執行shell命令 $ sudo apt-get install parallel 例 7.5. parallel - build and execute shell command lines from standard input in parallel $ cat *.csv | parallel --pipe grep 13113 設置塊大小 $ cat *.csv | parallel --block 10M --pipe grep 131136688 原…

MySQL-InnoDB索引實現

聯合索引提高查詢效率的原理 MySQL會為InnoDB的每個表建立聚簇索引&#xff0c;如果表有索引會建立二級索引。聚簇索引以主鍵建立索引&#xff0c;如果沒有主鍵以表中的唯一鍵建立&#xff0c;唯一鍵也沒會以隱式的創建一個自增的列來建立。聚簇索引和二級索引都是一個b樹&…

Go語言-基本的http請求操作

Go發起GET請求 基本的GET請求 //基本的GET請求 package mainimport ("fmt""io/ioutil""net/http" )func main() {resp, err : http.Get("http://www.hao123.com")if err ! nil {fmt.Println(err)return}defer resp.Body.Close()body, …

釘釘設置jira機器人_這是當您機器學習JIRA票證時發生的事情

釘釘設置jira機器人For software developers, one of the most-debated and maybe even most-hated questions is “…and how long will it take?”. I’ve experienced those discussions myself, which oftentimes lacked precise information on the requirements. What I…