XDebug and VIM. Browsing array values

↘锁芯ラ 提交于 2019-12-07 03:40:01

问题


Is there any way to browse the data inside an array?

Currently I can only see $data[0] = (array) with no way knowing what's inside the array.

I can the values inside normal variables fine.

Is there a way to see inside the arrays? Maybe a command I'm not aware of?

Edit:

I found out I can use the command keys ,e to evaluate an array or object.

After I type ,e an /*{{{1*/ => eval: prompt shows up then I can type /*{{{1*/ => eval: $data[0] to see the values.

Except I get it in the following output format:

/*{{{1*/ => eval: $data[0]

$command = 'eval';

EVAL_RESULT = (array) ;

EVAL_RESULT = (string) 'stringfromdata0-1' ;

EVAL_RESULT = (string) 'stringfromdata0-2' ;

EVAL_RESULT = (array) 'stringfromdata0-3' ;

This only does half of what I want it to do. Is there any way to output the keys of the array? It only shows me the values, but the keys are shown as "EVAL_RESULT" instead of the their perspective key names of the array.


回答1:


Edit debugger.vim file (~/.vim/plugin/debugger.vim) and find a line similar to

let g:debuggerMaxDepth = 1

increase the depth varibale to a reasonable amount (5 should be enough) save and restart vim.




回答2:


Also, you can wrap your expression in var_export(<expr>, true), and it will show you the full object.




回答3:


You can enter the vim command ,e in a xdebug session.

From there you can evaluate any php line you want; for example

print_r($data);

and submit it with Enter

Note: This will output to your php-cli stdout, or possibly output buffer if you are inside a ob_start block; Or if you are accessing from a browser, it may not output until the entire php request is completed. You may be able to flush a partial output buffer to a browser, but you'll have to Google that one for yourself.


I Posted this as an answer even though its posted in the OP's question because I don't read the OP's question if I'm looking for an answer and I want to make sure people can find it! If the OP posts his answer as an answer and ping's me I'd be happy to delete this one.




回答4:


Never got it the way I wanted it to work. Instead I found something way better.

Using Vundle I installed the VIM debugger for xdebug below:

https://github.com/joonty/vdebug

I'll post a screenshot whenever I get a chance.

Works like a charm though.



来源:https://stackoverflow.com/questions/5534975/xdebug-and-vim-browsing-array-values

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!