emiliomg/debug

This package is abandoned and no longer maintained. No replacement package was suggested.

Pretty Print Debug Messages with backtrace

1.0.0 2015-05-15 11:45 UTC

This package is not auto-updated.

Last update: 2018-11-18 16:51:51 UTC


README

Examples

Small Pretty-Printer for debug outputs incl. information about the calling file:line.

Short demonstration:

foo.php:

<?php
  require('vendor/autoload.php');
  kd('Hello World');
  kdd('Hello World, Bye!'); // kdd is short for kd die"
  kd('I will not work, because a die was called the line before');

A run of foo.php outputs:

------------------------------------------------------------
/pfad/zu/foo.php:3
------------------------------------------------------------
Hello World
------------------------------------------------------------

------------------------------------------------------------
/pfad/zu/foo.php:4
------------------------------------------------------------
Hello World, Bye!
------------------------------------------------------------
A little more complexity

foo.php:

<?php
  require('vendor/autoload.php');
  require('bar.php');

  kd('Hello from Foo!', 'Title from Foo');

  $bar = new Bar();
  $bar->baz();

bar.php:

<?php

  class Bar
  {
      public function baz()
      {
          $text = array(
              'One' => 'Hello',
              'Two' => 'from',
              'Three' => 'Bar',
              'Four' => '!'
          );
          kd($text, 'The title in Bar');
      }
    }

A run of foo.php renders:

------------------------------------------------------------
/pfad/zu/foo.php:5
------------------------------------------------------------
--Text from Foo--
Title from Foo!
------------------------------------------------------------

------------------------------------------------------------
/pfad/zu/bar.php:13
------------------------------------------------------------
--The title in Bar--
Array
(
    [One] => Hello
    [Two] => from
    [Three] => Bar
    [Four] => !
)

------------------------------------------------------------