<?php require_once('vendor/autoload.php'); $debug = new \PHPixie\Debug(); try{ throw new \Exception("test"); }catch(\Exception $e) { // $debug->exceptionMessage($e); } echo "\n-------\n"; // // //( ) $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");
Exception: test 5 6 try{ > throw new \Exception("test"); 8 9 }catch(\Exception $e) { #0 D:\debug\examples\exceptions.php:7 ------- ErrorException: substr() expects at least 2 parameters, 0 given 36 public function c() 37 { >> substr(); 39 } 40 } #0 D:\debug\examples\exceptions.php:38 #1 D:\debug\examples\exceptions.php:38 substr() #2 D:\debug\examples\exceptions.php:33 Test->c('pixie', array[2], stdClass) #3 D:\debug\examples\exceptions.php:27 Test->b('pixie', array[2]) #4 D:\debug\examples\exceptions.php:43 Test->a('pixie') Logged items:
<?php require_once('vendor/autoload.php'); use PHPixie\Debug; $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");
'Array dump:' Array ( [0] => 1 ) 'Short array dump:' array[1] 'Object dump:' stdClass Object ( [t] => 1 ) 'Short object dump:' stdClass 'Dump trace with parameters' #0 D:\debug\examples\dumping.php:37 PHPixie\Debug::trace() #1 D:\debug\examples\dumping.php:32 Test->c('test', array[2], stdClass) #2 D:\debug\examples\dumping.php:26 Test->b('test', array[2]) #3 D:\debug\examples\dumping.php:42 Test->a('test')
use PHPixie\Debug; $debug = new Debug(); Debug::log("test"); Debug::log(array(3)); class Test { public function a($string, $num) { Debug::logTrace(); } } $t = new Test(); $t->a("test", 5); // $debug->dumpLog();
Logged items: [0] D:\debug\examples\logging.php:7 'test' [1] D:\debug\examples\logging.php:8 Array ( [0] => 3 ) [2] D:\debug\examples\logging.php:16 #0 D:\debug\examples\logging.php:16 PHPixie\Debug::logTrace() #1 D:\debug\examples\logging.php:20 Test->a('test', 5)
<?php use PHPixie\Debug; $debug = new Debug(); // 'true' // // $debug->registerHandlers(true); Debug::log("test"); echo("Logged messages will be printed below");
Logged messages will be printed now Logged items: #0 D:\debug\examples\log_handler.php:13 'test'
git clone https://github.com/phpixie/debug cd debug/examples # curl -sS https://getcomposer.org/installer | php php composer.phar install php exceptions.php php logging.php php log_handler.php php dumping.php
Source: https://habr.com/ru/post/257625/
All Articles