<?php require_once 'vendor/autoload.php'; use PHPixie\Debug; $debug = new Debug(); Debug::log("test"); Debug::log(array(3)); class Test { public function a($string, $num) { //Note how the trace //Will contain function parameters Debug::logTrace(); } } $t = new Test(); $t->a("test", 5); //The values will be printed //only after this call $debug->dumpLog();
$debug = new Debug(); Debug::dump("Array dump:"); Debug::dump(array(1)); Debug::dump("Short array dump:"); Debug::dump(array(1), true); $object = (object) array('t' => 1); Debug::dump("Object dump:"); Debug::dump($object); Debug::dump("Short object dump:"); Debug::dump($object, true); Debug::dump("Dump trace with parameters"); class Test { public function a($string) { $array = array(1, 2); $this->b($string, $array); } public function b($string, $array) { $object = (object) array('t' => 1); $this->c($string, $array, $object); } public function c() { Debug::trace(); } } $t = new Test(); $t->a("test");
//Pretty printing exceptions try { throw new \Exception("test"); } catch (\Exception $e) { $debug->exceptionMessage($e); } echo "\n-------\n"; //Register handlers to pretty print //all exception automatically. //Logged items will also be printed $debug->registerHandlers(); class Test { public function a($string) { $array = array(1, 2); $this->b($string, $array); } public function b($string, $array) { $object = (object) array('t' => 1); $this->c($string, $array, $object); } public function c() { substr(); } } $test = new Test(); $test->a("pixie");