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.mzph.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…