Mac+IDEA安装PHP及搭建调试环境xdebug

本文介绍如何使用Homebrew安装PHP,并通过下载压缩包的方式安装Xdebug进行调试环境配置。包括配置IDEA、设置xdebug.ini文件及终端验证安装是否成功等步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

安装php

安装xdebug并配置调试环境

  1. 下载压缩包 https://xdebug.org/download.php
    注意版本对应:
    在这里插入图片描述
  2. 解压tar压缩包后,进入目录xdebug-2.7.0
  3. terminal中搜索phpize
➜  xdebug-2.7.0  whereis phpize
/usr/bin/phpize

执行这个命令

➜ phpize
  1. 依次执行
./configure --enable-xdebug
make
make install
  1. 由于xdebug和php内置的其他一些扩展有兼容性问题,需要执行:
//该目录也在xdebug解压包下
$ cd debugclient
$ ./configure --with-libedit
$ make
$ make install
  1. IDEA中修改配置
    在这里插入图片描述
    弹出下面的框:
    在这里插入图片描述
    点击2后,tab页中打开
    在这里插入图片描述
    编辑该文件,在末尾添加
[Xdebug]
zend_extension ="/usr/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so"
xdebug.remote_host=127.0.0.1
xdebug.remote_port = 9000
xdebug.remote_mode = "req"
xdebug.remote_enable = 1
xdebug.remote_handler = dbgp
xdebug.idekey = "netbeans-xdebug"
xdebug.profiler_enable=on
xdebug.profiler_enable_trigger = 0
xdebug.trace_output_dir="/Applications/devTools/xdebug-2.7.0/xdebug-2.7.0/xdebuginfo"
xdebug.profiler_output_dir="/Applications/devTools/xdebug-2.7.0/xdebug-2.7.0/xdebuginfo"
xdebug.auto_trace=on
xdebug.collect_params=on
xdebug.collect_return=on
xdebug.show_exception_trace = On
xdebug.remote_autostart = 0
xdebug.remote_connect_back=1
xdebug.collect_vars = On
xdebug.show_local_vars=0
xdebug.var_display_max_children=128
xdebug.var_display_max_data=512
xdebug.var_display_max_depth=5

如果不能保存,就要先修改该文件的权限,该文件一般在/etc 目录下,如果不是这个名称,可以复制一个改名。
另外还需要配置xdebug.ini文件,该文件在xdebug解压包目录下,在该文件中添加:

zend_extension ="/usr/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so"
xdebug.remote_host=127.0.0.1
xdebug.remote_port = 9000
xdebug.remote_mode = "req"
xdebug.remote_enable = 1
xdebug.remote_handler = dbgp
xdebug.idekey = "netbeans-xdebug"
xdebug.remote_autostart = 0

如果不添加,我试了php代码使用debug运行会报错。

操作完后,在终端中执行php -m,如果看到有xdebug模块说明安装成功。

如果有其他问题,欢迎留言。。。。。。。。。。。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

每天进步一点_点

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值