一直都是用var-dump, echo, die 输出变量来调试php,终于有一天,怒了。找了找,发现了geben, 感觉挺方便。安装方法如下:
- geben的安装
下载geben
cd geben-0.26/
make
Copy `dbgp.elc’, `geben.elc’ 和 `tree-widget’ 目录到emacs load path下 - xdebug的安装
- 使用方式
.emacs 中加入:(autoload ‘geben “geben” “PHP Debugger on Emacs” t) - gebenmode 下快捷键
spc step into/step over
i step into
o step over
r step out
g run
c run to cursor
b set a breakpoint at a line
B set a breakpoint interactively
u unset a breakpoint at a line
U clear all breakpoints
\C-c b display breakpoint list
> set redirection mode
\C-u t change redirection mode
d display backtrace
t display backtrace
v display context variables
\C-c f visit script file
w where
q stop - 参考
http://code.google.com/p/geben-on-emacs/ geben
http://www.xdebug.org/ xdebug
tar xvfz xdebug-2.1.0.tgz
cd xdebug-2.1.0.tgz
phpize
./configure –enable-xdebug
make;make install
修改php.ini 增加 zend_extension_ts=”/wherever/you/put/it/xdebug.so”和zend_extension=”/wherever/you/put/it/xdebug.so”
php.ini增加xdebug配置内容:
[xdebug]
xdebug.remote_enable = On
xdebug.remote_enable = On
启动emacs
M-x geben
直接访问一个php页,如果设置了手工触发,则需要增加url参数,类似于:http://www.example.com/test.php?XDEBUG_SESSION_START=1
如果是命令行调试,则export XDEBUG_CONFIG=”idekey=session_name”;php myscript.php