PhpStorm+Xampp+Xdebug配置

本文介绍如何在XAMPP环境下配置Xdebug进行PHP调试,并在PhpStorm中设置调试环境。包括修改httpd.conf及php.ini,配置Xdebug参数,以及在PhpStorm中完成调试设置。

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

1 Xampp


安装好xampp,配置 httpd.conf
191/221 行 DocumentRoot 路径改为 “F:/PHP” (我的工作空间),以后项目就放在这个文件夹里。
配置 php.ini
Windows 下
[XDebug]
zend_extension = “E:\Software\Develop\xampp\php\ext\php_xdebug.dll”
xdebug.profiler_append = 0
xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = 0
xdebug.profiler_output_dir = “E:\Software\Develop\xampp\tmp”
xdebug.profiler_output_name = “cachegrind.out.%t-%s”
xdebug.remote_enable = on
xdebug.remote_handler = “dbgp”
xdebug.remote_host = “127.0.0.1”
xdebug.trace_output_dir = “E:\Software\Develop\xampp\tmp”
xdebug.remote_port = 9000重启 Apache
如果是Linux 需要下载 xdebug
http://code.activestate.com/komodo/remotedebugging/
解压后找到合适版本的xdebug.so并将其复制到/opt/lampp/lib/php/extensions/中。然后修改/opt/lampp/etc/php.ini文件,
在其最后加上

[XDebug]
zend_extension=”/opt/lampp/lib/php/extensions/xdebug.so”
xdebug.remote_enable=true
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.profiler_enable=1
xdebug.profiler_output_dir=”/opt/lampp/tmp”
lampp restart

2 PhpStorm


2.1 进入File>Settings>PHP>Servers,添加一个 Server
Name : localhost
Host : localhost
Port : 80
Debugger : Xdebuger

2.2 进入File>Settings>PHP>Debug
Debug port : 9000

2.3 打开 Edit Configurations
这里写图片描述
添加一个 PHP Web Application
这里写图片描述

运行时 就用这个 Web 运行调试,搞定。
还不行就试试修改 上图中的Defaults,我把 server都改成了自己的localhost ,浏览器改成了firefox。
成果就是设置好断点,debug 运行,或者直接 shift + F9 则会自动打开火狐浏览器并且停留在断点处。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值