PHP 7 replacement for xdebug tracing

I started working with PHP 7.0.0-dev and, at least at the time I wrote this, xdebug and Zend debugger are not currently compatible with it, because of the extension API changes.  If you need something better than a simple NOTICE or ERROR, then this will probably work for you.

The code is fairly clean, but could use some improvements, and if you have any suggestions or insights, please comment.

Some Notes

  • Some really nice debugging classes and so forth exist (like kint), but they're huge and do way more than I need them to, and also most won't easily mimic xdebug, if at all.
  • It does not work as well or provide as much detail as xdebug's stack tracing, but it's pretty close and may work for most people.
  • It doesn't provide remote debugging or anything like that, obviously
  • The code, ironically, does not take advantage of any improves made within PHP 7, so it can be used with older versions, but I've only tested it with 5.5 and 5.6

Instructions

I put the code at the top of my entry point (index.php for me) before any other code (autoloader, etc). Of course if you don't have an entry point, you can probably put it in some other global file if you want, such as a config file.

I also put it in the condition of "if (PHP_MAJOR_VERSION == 7) {…}", just in case I test my app with other versions as well.