Debugging FLOW3 Applications

Throughout the years my team and I have gathered quite some experience with debugging complex PHP applications like one FLOW3 is. Since FLOW3 controls the lifecycle, dependencies, proxy classes and scopes of almost all objects used in an application or the framework itself, the central parts contain a lot of references to other objects which in turn might refer back to central places like the Object Manager.

Debuggers are very helpful – if you're not using PHP. Honestly, I haven't yet seen anybody who was reliably using Xdebug or Zend Debugger by using an IDE such as Zend Studio, Eclipse or Netbeans. The best results I had so far are Netbeans with Xdebug (nice integration, but inspection of variables is not really working) and Xdebug with MacGDBp (works most of the time). That said, I'm still one of those old-school programmers who tend to echo variables with PHP's var_dump() command.

Unfortunately var_dump() doesn't go well with large nested and recursive object structures. If the Object Manager is connected to one of the displayed objects, the browser will simply collapse under the amount of data pushed to it. This has been a problem since the beginning of FLOW3 development and we always wished there was a debug function which takes the special needs of FLOW3 into account. Yesterday I was again debugging a part of some FLOW3 app and concluded to solves this once and for all with a custom var_dump() method.

In the screenshot below (sorry, this blog doesn't support image resizing yet, just open the image in a new window) you can see a typical dump of the new function. If you use \F3\var_dump() instead of PHP's built-in function, you'll not only get a filtered view of the object structure (the properties of Object Manager and friends are not displayed), but also some helpful information about each variable. You can see at one glance, if the object is persistable (entity or value object), what scope it has (prototype, singleton, session), if it is proxied by the AOP framework and what UUID and object hash it has (move the mouse over the scope and persistence tags). Each instance is only rendered once – if some other object refers to it at a later stage, only its class is mentioned again in italics. Click on it for jumping to the first occurrence of this instance.

Although this is only a start (I have many more features for this in mind), I hope that it'll help you as well with your FLOW3 development. Let me know your ideas and comments!

Leave a reply