首页 » Web前端 » vim操作php技巧_Vim运用XDebug支持Php调试

vim操作php技巧_Vim运用XDebug支持Php调试

访客 2024-12-13 0

扫一扫用手机浏览

文章目录 [+]

一、事理

Php调试的办法有很多,最常用的便是通过打印来办理,打印带来的毛病也比较明显,便是不足直不雅观,而且繁琐,打的不准的话,会摧残浪费蹂躏很多韶光,以是这里给大家先容一种常用调试办法,利用xdebug来实现,这次我们将和Vim结合,详细事理如下:

vim操作php技巧_Vim运用XDebug支持Php调试

二、xdebug安装配置

vim操作php技巧_Vim运用XDebug支持Php调试
(图片来自网络侵删)

1、为php安装xdebug.so扩展

wget https://xdebug.org/files/xdebug-2.5.4.tgz tar xf xdebug-2.5.4.tgz cd xdebug-2.5.4 phpize ./configure --enable-xdebug make cp modules/xdebug.so /usr/lib64/php/modules/

2、配置php

cd /etc/php.d

新建xdebug.ini,填入如下内容:

zend_extension =/usr/lib64/php/modules/xdebug.so xdebug.remote_enable=on xdebug.remote_handler=dbgp xdebug.remote_host=127.0.0.1 xdebug.remote_port=9010

3、重启php-fpm

sudo service php-fpm restart

三、Vim插件安装配置

往.vimrc中插入

Bundle 'joonty/vdebug' \"大众=================================== \"大众xdebug \"大众================================== let g:vdebug_options = {} let g:vdebug_options[\"大众port\"大众] = 9010

在命令模式下,实行BundleInstall

四、详细操作

1、打开你要调试的php文件

2、光标移动到你要调试的行,按下<F10>添加一个行断点

3、按下<F5>,开始调试状态,在vim底下会涌现类似下面的信息

4、打开浏览器,输入你的Url,并在末端添加 ?XDEBUG_SESSION_START=1,例如,http:://localhost/index.php → http://localhost/index.php?XDEBUG_SESSION_START=1

然后刷新页面,在vim中就会看到如下信息:

五、调试指南

<F5>: start/run (to next breakpoint/end of script)

<F2>: step over <F3>: step into <F4>: step out <F6>: stop debugging (kills script) <F7>: detach script from debugger <F9>: run to cursor <F10>: toggle line breakpoint <F11>: show context variables (e.g. after \"大众eval\"大众) <F12>: evaluate variable under cursor :Breakpoint <type> <args>: set a breakpoint of any type (see :help VdebugBreakpoints) :VdebugEval <code>: evaluate some code and display the result <Leader>e: evaluate the expression under visual highlight and display the result

标签:

相关文章

大数据时代分词技术的革新与应用

随着互联网的飞速发展,大数据已成为当今时代的重要特征。在众多大数据技术中,分词技术作为自然语言处理的基础,其重要性不言而喻。本文将...

Web前端 2024-12-15 阅读0 评论0