Mac 安装配置php xdebug

本地调试

0、原理图

https://paper.seebug.org/308/

测试demo构建方法

新建空白项目,目录选择Apache默认项目目录

1、下载xdebug

https://xdebug.org/files/xdebug-2.9.0.tgz

具体自己的版本要根据的方法得出

2、使用官方检测指导工具

https://xdebug.org/wizard

将phpinfo()打印内容的网页源码复制到框里,点击检测,会得到提示

然后根据提示进行操作

Instructions

  1. Download xdebug-2.9.0.tgz

  2. Install the pre-requisites for compiling PHP extensions. On your Mac, we only support installations with 'homebrew', and brew install php && brew install autoconf should pull in the right packages.

  3. Unpack the downloaded file with tar -xvzf xdebug-2.9.0.tgz

  4. Run: cd xdebug-2.9.0

  5. Run: phpize (See the FAQ if you don't have phpize).

    As part of its output it should show:

     
    Configuring for:
    ...
    Zend Module Api No:      20180731
    Zend Extension Api No:   320180731

    If it does not, you are using the wrong phpize. Please follow this FAQ entry and skip the next step.

  6. Run: ./configure

  7. Run: make

  8. Run: cp modules/xdebug.so /usr/local/lib/php/pecl/20180731

  9. Edit /usr/local/etc/php/7.3/php.ini /usr/local/etc/php/7.3/php.ini and add the line zend_extension = /usr/local/lib/php/pecl/20180731/xdebug.so Make sure that zend_extension = /usr/local/lib/php/pecl/20180731/xdebug.so is below the line for OPcache.

  10. Restart the webserver

sudo apachectl restart

安装路径:/Users/taylor/workSoft/php-debug

3、配置php.ini

vim /usr/local/etc/php/7.3/php.ini

大写G到最后一样,添加配置

 
 
[xdebug]
zend_extension=/usr/local/lib/php/pecl/20180731/xdebug.so
xdebug.remote_enable=1
xdebug.remote_autostart=1
xdebug.idekey=PHPSTORM
xdebug.remote_handler=dbgp
xdebug.remote_connect_back=1
xdebug.remote_host=localhost
xdebug.remote_port=9050
xdebug.scream=0
xdebug.show_local_vars=1

参数分析:

  1. xdebug.remote_connect_back = 0 ,也是 Xdebug 的默认方式,这种情况下,Xdebug 在收到调试通知时会读取配置 xdebug.remote_host 和 xdebug.remote_port ,默认是 localhost:9000,然后向这个端口发送通知,这种方式只适合单一客户端开发调试

  1. 另外一种方式则是不绑定IP,xdebug.remote_connect_back = 1, Xdebug根据请求来源(REMOTE_HOST)来发起调试。示例图如下:

  1. remote_connect_back与remote_host,remote_port的关系

    xdebug.remote_connect_back = 1 //如果开启此,将忽略下面的 xdebug.remote_host 的参数,也就是说不会读取phpstorm中xdebug插件dbgp proxy中的参数,任何ip调用调试都会返回调试信息到该IP的remote_port端口中。

  2. remote_host和remote_port

    xdebug.remote_host=192.168.x.x //注意这里是,客户端的ip<即IDE的机器的ip,不是你的web server>xdebug.remote_port = 9001 //注意这里是,客户端的端口<即IDE的机器的ip,不是你的web server>

  3. 最终实验结果是,xdebug.remote_port 任何没被占用的端口都可以

重启php-fpm

sudo killall php-fpm sudo php-fpm

或者 /etc/init.d/php73-fpm reload

再打印phpinfo就可以看到

4、配置phpstorm

debug配置

servers配置

5、php项目运行方式

1.phpstorm ide作为调用者

开启监听后,直接点击小虫子进行运行,浏览器中会自动弹出窗口,地址类似于

http://localhost/helloDebug/hello.php?XDEBUG_SESSION_START=17598

自动带了xdebug_session

2.使用xdebug helper插件

单击左键后,点击debug,开启插件

然后浏览器中输入想要调试的地址即可 http://localhost/helloDebug/hello.php

效果图

参考:

https://drops.blbana.cc/2019/09/27/PHPStorm%E8%BF%9C%E7%A8%8B%E8%B0%83%E8%AF%95%E7%8E%AF%E5%A2%83%E6%90%AD%E5%BB%BA%E4%BB%A5%E5%8F%8A%E5%8E%9F%E7%90%86/

https://www.jianshu.com/p/da179e363318

Mac 使用自带php和Apache 安装配置Xdebug 开启本地调试模式的更多相关文章

  1. centos tomcat/resin安装配置 卸载系统自带的java tomcat安装配置 安装JDK resin安装配置 第二十八节课

    centos  tomcat/resin安装配置  卸载系统自带的java  tomcat安装配置  安装JDK   resin安装配置    第二十八节课 tomcat和java都不需要编译 tom ...

  2. Apache安装配置步骤

    注释:这里以Linux 红帽商业版为例~~~~~~~纯手打啊 Apache安装配置步骤 准备:关闭其他虚拟设备 #/etc/init.d/libvirtd stop #/etc/init.d/xend ...

  3. Ajax - Apache安装配置

    apache安装配置 1.安装wamp2.配置根路径3.默认的网站根路径是安装目录的www子目录,如果不想使用默认目录,可以自己配置.配置方式如下: --找到文件wamp\bin\apache\Apa ...

  4. Ubuntu 14.04 apache安装配置

    http://jingyan.baidu.com/article/6d704a130c8a0d28da51ca5f.html Ubuntu 14.04 apache安装配置 1.安装 ~# apt-g ...

  5. 安装配置Xdebug模块详解

    1.XDebug安装配置 (1)下载XDebug下载地址:http://www.xdebug.org/必须下载跟机器上安装的php匹配的版本才行.具体下载方法如下:将phpinfo网页的源代码拷贝到h ...

  6. Mac OS 10.10.3下Apache + mod_wsgi配置【一】

    [一] 首先,MAC是自带Apache的,在/private/etc/apache2路径下,能够使用apachectl -v查看版本号.我的版本号例如以下: Server version: Apach ...

  7. Center OS 7 Apache安装配置

    感谢:https://blog.csdn.net/u014157384/article/details/79497761 该作者的帮助. 自己购买了国外的服务器,想把我的网页放到服务器,网页是以web ...

  8. 4-STM32物联网开发WIFI(ESP8266)+GPRS(Air202)系统方案数据篇(云端电脑(Windows)安装配置数据库,使用本地Navicat for MySQL和手机APP 远程连接测试)

    3-STM32物联网开发WIFI(ESP8266)+GPRS(Air202)系统方案数据篇(安装配置数据库,使用Navicat for MySQL和手机APP 连接测试) 根据前面的教程把软件复制到云 ...

  9. Centos 下php安装配置xdebug扩展

    2018年05月02日 19:54:42 杨汉松 阅读数:44   1.下载安装xdebug 获取xdebug wget http://www.xdebug.org/files/xdebug-2.3. ...

随机推荐

  1. BL8810|USB 2.0单芯片解决方案闪存读卡器|BL8810替代GL823K

    创惟GL823K是一款USB 2.0单LUN读卡器控制器,可支持SD/MMC/MSPRO闪存卡.它支持USB 2.0高速传输,将Digital TM(SD).SDHC.SDXC.Mini DTM.Mi ...

  2. 编写Java程序,使用抽象类和抽象方法构建不同动物的扑食行为,抽象类设计

    返回本章节 返回作业目录 需求说明: 不同的动物都有进食的行为,但是在进食前需要捕获到食物后才可以进食. 要求定义一个抽象的动物类,该类中有一个抽象的捕食方法,和一个非抽象的进食方法.在进食方法中调用 ...

  3. C# UTF8的BOM导致XML序列化与反序列化报错:Data at the root level is invalid. Line 1, position 1.

    最近在写一个xml序列化及反序列化实现时碰到个问题,大致类似下面的代码: class Program { static void Main1(string[] args) { var test = n ...

  4. AWS修改RDS时区

    查看 RDS 当前时区 默认情况下,AWS 的 RDS 采用的是 UTC 时间.而我们地区一般位于东八区,因此我们本地的时间是 UTC+8. 连接到 RDS 上,查询当前实例的时区. show var ...

  5. 灵雀云Kube-OVN进入CNCF沙箱,成为CNCF首个容器网络项目

    昨日,云原生计算基金会 (CNCF) 宣布由灵雀云开源的容器网络项目Kube-OVN 正式进入 CNCF 沙箱(Sandbox)托管.这是全球范围内首个被CNCF纳入托管的开源CNI网络项目,也是国内 ...

  6. UVA 10815 Andy's First Dictionary (C++ STL map && set )

    原题链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_proble ...

  7. 使用 SourceGenerator 简化 Options 绑定

    目录 摘要 Options 绑定 使用 SourceGenerator 简化 如何 Debug SourceGenerator 如何 Format 生成的代码 使用方法 SourceCode & ...

  8. ES6随笔D1

    1.数值解构赋值 ES6 允许按照一定模式,可以从数组中提取值,按照对应位置,对变量赋值,这被称为解构. 解构赋值的规则是,只要等号右边的值不是对象或数组,就先将其转为对象.由于undefined和n ...

  9. windows10双系统删除linux

    问题 在这里删除后会发现有残留一个引导区,几百m(下图已经删除完),而且启动会进linux引导,然后必须f12进入选择启动项才可以启动windows 解决方法 使用删除引导就可以了 再使用傲梅分区助手 ...

  10. 如何根据经纬度计算地面上某点在XYZ空间直角坐标系中的坐标

    如何根据经纬度计算地面上某点在XYZ空间直角坐标系中的坐标 /** * @param r: number 到地心的距离 * @param lon: number 经度 * @param lat: nu ...