0

I'm having hard time using ZF2 because I cannot use debug_print_backtrace() like I would use it normally.

It is showing me huge amount of data from Zend\Mvc\MvcEvent object. Output looks something like this:

#1  Zend\Mvc\Controller\AbstractActionController->onDispatch(Zend\Mvc\MvcEvent Object ( .... A LOT OF DATA
,[SERVER_SOFTWARE] => Apache/2.2.20 (Ubuntu),[SERVER_NAME] => zf.localhost.com,[SERVER_ADDR] => 127.0.0.1,[SERVER_PORT] => 80, .... SOME SERVER PARAMETERS
Apache/2.2.20 (Ubuntu) Server at zf.localhost.com Port 80
...

Is there a way to not show all this MvcEvent content but still see backtrace with parameters?

wormhit
  • 3,687
  • 37
  • 46

2 Answers2

2

If you're just trying to remove the first row (i.e. the MvcEvent), remember - debug_backtrace() returns an array. Nothing prevents you from shifting or popping the data you don't want!

(array_shift() - removes the first element of an array. array_pop() - removes the last. They come in pretty handy in cases like these :-) )

Sébastien Renauld
  • 19,203
  • 2
  • 46
  • 66
  • Hi, thanks for answer! It is one way to do it. But it will not help me in debug_print_backtrace(). Maybe there is another way to solve this? – wormhit Nov 17 '12 at 22:06
  • Oh, sorry! I didn't see you were using debug_print_backtrace, assumed you were using the array form. Switch to the array returning function, or output-buffer the printout from debug_print_backtrace and edit out (using regular expressions or standard string functions) the values you don't want? – Sébastien Renauld Nov 17 '12 at 22:08
  • Yes, I think you're right. I will need to create some globally available debug_backtrace function that will filter backtrace results so it is usable again. I will accept your answer tomorrow if nothing better will show up. Cheers! – wormhit Nov 17 '12 at 22:13
  • What I was getting at is that you can selectively kill parameters using a combination of both - i.e. stripping out parameters for the first part of the dump, but not for the rest. – Sébastien Renauld Nov 17 '12 at 22:31
2

Do you have XDebug installed? I found XDebug invaluable whilst debugging ZF2 issues as you can limit the object depth displayed using var_dump and a few other commands.

An example of this and more information can be found at http://xdebug.org/docs/display

You could then use var_dump(debug_backtrace()) for a less verbose output.

DrBeza
  • 2,241
  • 1
  • 16
  • 18