您的位置:首页 > 编程语言 > PHP开发

配置phpstorm + xdebug 调试php

2016-07-26 00:00 323 查看
安装phpstorm,注册码什么的对天朝来说不是四儿。

获取xdebug:git clone git://github.com/xdebug/xdebug.git

cd到目录下,使用phpize将其添加为动态扩展,

报错,Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF environment variable is set correctly and then rerun this script.

于是乎,brew install autoconf安装。

再phpize成功,之后编译文件:

./configure --enable-xdebug && make && make install

小解释下,linux下的C文件,./configure是检查平台目标特征,--prefix参数指定软件安装在参数文件夹下,可执行文件在文件夹下bin目录里,若不写默认在/usr/bin。--enable启动些默认关闭的特性。make是编译make install是安装,都通过makefile来指定

编译完成得到xdebug.so

修改php.ini,添加节点:

[Xdebug]
zend_extension="/Users/guoguo/xdebug/xdebug-2.4.0/modules/xdebug.so"
xdebug.remote_enable = on
;xdebug.remote_handler=dbgp
xdebug.remote_host="127.0.0.1"
xdebug.remote_port=9000
xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = off
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.remote_autostart = on

实际使用中发现MAMP下的php中已有注释掉的[xdebug],打开即可用,后装配的反而不能用,待考证。

打开phpstorm,打开phpstorm->preferences->Languages&Frameworks->php,添加一个解释器interpreter,选到php程序,刷新可看到Debugger由None变成Xdebug,即可使用
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: