2

I know with Xdebug you can change your xdebug.collect_params settings, so that the error messages include more information about the parameters used in the calls. (There's a nice explaination about it here)

However, the string representations of my objects are very large and unreadable.

large and unreadable object representations

I already have some good toString implementations which just returns a unique id, so it would be really nice if I could let xdebug use __toString() instead of a full serialisation.

Is this (or any other customisation of the parameter formatting) possible?

I guess in theory I could try implementing custom representations through __sleep() but I actually need the default serialisation mechanisms to save objects across requests.

2
  • 1
    Sidenote: in php 5.6 the __debugInfo method has been added. I don't really know but if xdebug uses var_dump() then you could move your __toString() logic to __debugInfo(). Commented Feb 27, 2015 at 7:21
  • yes, seems this is exactly the solution. Support for __debugInfo is implemented in the latest version of xdebug. Now I just need to wait for a WAMP update with PHP 5.6 ;) related: stackoverflow.com/questions/26835450/… Commented Feb 27, 2015 at 11:12

2 Answers 2

2
+25

There are tools that provide an intuitive and interactive way to display exceptions and stack traces. Thus you can have all the necessary details and still have an uncluttered UI. Consider the following:

When debugging, you will usually want as much (useful) information as possible, so instead of removing the (at the moment) unnecessary information, try using a library that hides the information by default, but ensures it is there when you need it.


* The Symfony exception handler seems to be able to work standalone (no other dependencies on Symfony judging from composer.json, though I haven't tried it yet). The documentation says:

The ExceptionHandler class catches uncaught PHP exceptions and converts them to a nice PHP response. It is useful in debug mode to replace the default PHP/XDebug output with something prettier and more useful.

Sign up to request clarification or add additional context in comments.

5 Comments

this looks really nice, though my IDE relies on Xdebug for it's debugging work. Not sure if it would be wise to use them together?
oh and in the demo I don't see any information on the value of the parameters that were used?
Admittedly, I haven't used Whoops before and it does not seem to be able to track the passed parameters. However, I have been using both NetteDebug and Symfony\Debug in projects and both support showing the passed arguments. I have updated the post with new links.
thanks, it's a good list. It might come in handy some day, but for now I'm really looking for a solution using xdebug. and it seems __debugInfo is the answer
By coincidence I came across the League project which has a nice set of packages, including an error handler called BooBoo. It is a fairly young project and does not contain a pretty error page formatter yet, however the project provides a solid OOP foundation for customizing the error output. I did not add it to the list as it does not yet provide an "intuitive and interactive way to display exceptions".
1

As pointed out in the comment above:

PHP 5.6 supports __debugInfo(). A patch for this method has been submitted to the xdebug repo in dec 2014 and should be released soon.

See also: How to get __debugInfo to work with XDebug?

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.