From 62df2b9155f8821b7bfa1a7b5fb292dad82cc64a Mon Sep 17 00:00:00 2001 From: KOLANICH Date: Wed, 30 Apr 2014 18:39:08 +0400 Subject: [PATCH] added namespaces fixed string rendering (added support for unicode strings) And other minor fixes PS droped compatibility with php 4 --- .php_cs | 1 - README.md | 5 +- composer.json | 4 +- dBug.php | 495 +++++++++++++++++++++++++++----------------------- tests.php | 49 ++--- 5 files changed, 296 insertions(+), 258 deletions(-) diff --git a/.php_cs b/.php_cs index c97a196..8b547e7 100644 --- a/.php_cs +++ b/.php_cs @@ -13,4 +13,3 @@ return Symfony\CS\Config\Config::create() ->fixers(array('-indentation','-braces','-psr0','-controls_spaces')) ->finder($finder) ; - diff --git a/README.md b/README.md index a008f40..cfac391 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,16 @@ dBug ==== - my mod of dBug A debug output library which is used to visualize different datatypes. Initially was developed by ospinto. For more info visit [http://kolanich.github.com/dBug/] +![ohloh stats](https://www.ohloh.net/p/php-dbug/widgets/project_partner_badge.gif) + ## Very very brief list of features -PHP version of ColdFusion’s cfdump. +Extended PHP version of ColdFusion’s cfdump. Outputs colored and structured tabular variable information. diff --git a/composer.json b/composer.json index 9808371..fbeaa5c 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name" : "KOLANICH/dBug", "type" : "library", "description" : "A debug output library which is used to visualize different datatypes.", - "keywords" : ["debug", "output", "table", "visualization"], + "keywords" : ["debug", "output", "table", "visualization","cfdump","ColdFusion"], "homepage" : "https://github.com/KOLANICH/dBug", "license" : "GPL-2.0", "authors" : [{ @@ -17,7 +17,7 @@ } ], "require" : { - "php" : ">=4.1.0" + "php" : ">=5.2" }, "suggest" : { "ext-Reflection" : "to show protected and private info (now is only implemented for Exceptions)" diff --git a/dBug.php b/dBug.php index 949275d..7d9e427 100755 --- a/dBug.php +++ b/dBug.php @@ -1,4 +1,4 @@ -=0; $i--) { + for ($i=count($arrBacktrace)-1; $i>=0; $i--) { $arrCurrent = $arrBacktrace[$i]; - if(array_key_exists("function", $arrCurrent) && + if(array_key_exists("function", $arrCurrent) && (in_array($arrCurrent["function"], $arrInclude) || (0 != strcasecmp($arrCurrent["function"], "dbug")))) continue; $arrFile = $arrCurrent; - + break; } - - if(isset($arrFile)) { + + if (isset($arrFile)) { $arrLines = file($arrFile["file"]); $code = $arrLines[($arrFile["line"]-1)]; - + //find call to dBug class preg_match('/\bnew dBug\s*\(\s*(.+)\s*\);/i', $code, $arrMatches); - + return isset($arrMatches[1])?$arrMatches[1]:'[multiline]'; } + return ""; } - - function initializeHeader(&$header){ - if(!$this->bInitialized) { + + public function initializeHeader(&$header) + { + if (!$this->bInitialized) { $header = $this->getVariableName() . " (" . $header . ")"; $this->bInitialized = true; } } - + /*! @name rendering functions used to make tables representing different variables */ //!@{ - + //!creates the main table header /*! @param string $type name of the style of the header cell @param string $header the text of the header cell @param integer $colspan colspan property for the header cell */ - function makeTableHeader($type,$header,$colspan=2) { + public function makeTableHeader($type,$header,$colspan=2) + { $this->initializeHeader($header); $this->renderTableHeader($type,$header,$colspan); } - + //!draws the main table header /*! @param string $type name of the style of the header cell @param string $text the text of the header cell @param integer $colspan colspan property for the header cell */ - function renderTableHeader($type,$text,$colspan=0){ + public function renderTableHeader($type,$text,$colspan=0) + { echo ''; } - + //!renders table of 2 cells in 1 row [type][value] /*! @param string $headerStyle name of the style of the header cell @@ -137,7 +143,8 @@ class dBug { @param string $valueStyle name of the style of the value cell @param integer $colspan colspan property for the header cell */ - function renderPrimitiveType($headerStyle,$header,$value,$valueStyle=null,$colspan=0){ + public function renderPrimitiveType($headerStyle,$header,$value,$valueStyle=null,$colspan=0) + { if(!$valueStyle)$valueStyle=$headerStyle; $this->initializeHeader($header); echo '
bCollapsed) ? 'style="font-style:italic" ' : '').'class="dBug_'.$type.'Header" '.($colspan?'colspan='.$colspan:'').' onClick="dBug_toggleTable(this)">'.$text.'
@@ -147,38 +154,42 @@ class dBug { ''; } - + //!creates the table row header /*! @param string $type name of the style of the key cell @param string $header the text of the key cell */ - function makeTDHeader($type,$header) { + public function makeTDHeader($type,$header) + { echo 'bCollapsed ? ' style="display:none"' : '').'> \n"; } //!@} - - + //!prints error - function error($type) { + public function error($type) + { $error='Error: Variable cannot be a'; // this just checks if the type starts with a vowel or "x" and displays either "a" or "an" - if(in_array(substr($type,0,1),array("a","e","i","o","u","x"))) - $error.="n"; - return ($error." ".$type." type"); + if(in_array(substr($type,0,1),array('a','e','i','o','u','x'))) + $error.='n'; + + return ($error.' '.$type.' type'); } //!check variable type andd process the value in right way - function checkType($var) { + public function checkType($var) + { $type=gettype($var); - switch($type) { + switch ($type) { case 'resource': $this->varIsResource($var); break; @@ -207,43 +218,47 @@ class dBug { break; } } - + /*! @name functions for rendering different types */ //!@{ - + //!renders NULL as red-pink rectangle - function varIsNULL() { + public function varIsNULL() + { $this->makeTableHeader('false','NULL'); echo '
'.$value.'
'.$header.' '; } - + //!closes table row - function closeTDRow() { + public function closeTDRow() + { return "
'; } - + //!renders numeric types : integers and doubles - function varIsNumeric($var,$type) { + public function varIsNumeric($var,$type) + { $this->renderPrimitiveType('numeric',$type,$var); echo ''; } - + /*! renders string either as primitive type (if it is short (less than $embeddedStringMaxLength chars) and contains of one line) or line-by-line (otherwise) */ - function varIsString(&$var){ - if($var==''){ + public function varIsString(&$var) + { + if ($var=='') { $this->makeTableHeader('string','empty string'); echo ''; + return; } $length=strlen($var); $nv=htmlspecialchars($var,ENT_QUOTES | ENT_SUBSTITUTE,''); - $lines=preg_split('/\R/', $nv); + $lines=preg_split('/\R/u', $nv); $linesCount=count($lines); - if($linesCount==1 && $length<=self::$embeddedStringMaxLength){ + if ($linesCount==1 && $length<=self::$embeddedStringMaxLength) { $this->renderPrimitiveType('string','string ['.$length.']',$var); - }else{ + } else { $this->makeTableHeader('string','string ('.$length.' chars @ '.$linesCount.' lines)'); - foreach($lines as $num=>$line){ + foreach ($lines as $num=>$line) { $this->makeTDHeader('string',$num); echo ($line==''?'[empty line]':$line); $this->closeTDRow('string'); @@ -251,33 +266,34 @@ class dBug { } echo ""; } - + //!renders boolean variable - function varIsBoolean(&$var) { + public function varIsBoolean(&$var) + { $var?$this->renderPrimitiveType('boolean','boolean','TRUE','booleanTrue'):$this->renderPrimitiveType('boolean','boolean','FALSE','booleanFalse'); echo ''; } - - - function varIsArray(&$var) { + + public function varIsArray(&$var) + { $var_ser = serialize($var); array_push($this->arrHistory, $var_ser); - + $this->makeTableHeader('array','array'); - if(is_array($var)) { - foreach($var as $key=>$value) { + if (is_array($var)) { + foreach ($var as $key=>$value) { $this->makeTDHeader('array',$key); - + //check for recursion - if(is_array($value)) { + if (is_array($value)) { $var_ser = serialize($value); - if(in_array($var_ser, $this->arrHistory, TRUE)){ + if (in_array($var_ser, $this->arrHistory, TRUE)) { echo '*RECURSION*'; echo $this->closeTDRow(); continue; } } - + //if(in_array(gettype($value),$this->arrType)) $this->checkType($value); /*else { @@ -286,40 +302,38 @@ class dBug { }*/ echo $this->closeTDRow(); } - } - else echo ''.$this->error('array').$this->closeTDRow(); + } else echo ''.$this->error('array').$this->closeTDRow(); array_pop($this->arrHistory); echo ''; } - - - + //! checks wheither variable is object of special type (using varIs*Object), and renders it if it is generic object - function varIsObject(&$var) { + public function varIsObject(&$var) + { if($this->varIsSpecialObject($var))return 1; $var_ser = serialize($var); array_push($this->arrHistory, $var_ser); - - if(is_object($var)) { + + if (is_object($var)) { $this->makeTableHeader('object','object ( '.get_class($var).' )'); - if(method_exists($var,'__toString')){ + if (method_exists($var,'__toString')) { $str=$var->__toString(); - if($str!==null){ + if ($str!==null) { $this->makeTDHeader('string','[string representation]'); $this->varIsString($str); echo $this->closeTDRow(); } } $arrObjVars=get_object_vars($var); - foreach($arrObjVars as $key=>$value) { + foreach ($arrObjVars as $key=>$value) { //$value=(!is_object($value) && !is_array($value) && trim($value)=="") ? "[empty string]" : $value; $this->makeTDHeader('object',$key); - + //check for recursion - if(is_object($value)||is_array($value)) { + if (is_object($value)||is_array($value)) { $var_ser = serialize($value); - if(in_array($var_ser, $this->arrHistory, TRUE)) { + if (in_array($var_ser, $this->arrHistory, TRUE)) { echo (is_object($value)) ? '*RECURSION* -> $'.get_class($value) : '*RECURSION*'; echo $this->closeTDRow(); continue; @@ -332,42 +346,44 @@ class dBug { echo $this->closeTDRow(); } $arrObjMethods=get_class_methods(get_class($var)); - foreach($arrObjMethods as $key=>$value) { + foreach ($arrObjMethods as $key=>$value) { $this->makeTDHeader('object',$value); echo '[function]'.$this->closeTDRow(); } - if($var instanceof \Iterator){ - foreach($var as $key=>$value) { + if ($var instanceof \Iterator) { + foreach ($var as $key=>$value) { $this->makeTDHeader('array',$key); $this->checkType($value); echo $this->closeTDRow(); } } - } - else{ + } else { $this->makeTableHeader('object','object'); echo ''.$this->error('object').$this->closeTDRow(); } array_pop($this->arrHistory); echo ''; } - - function varIsSpecialObject(&$var){ + + public function varIsSpecialObject(&$var) + { if($this->varIsDBObject($var))return 1; - if($var instanceof Exception){ + if ($var instanceof \Exception) { $this->varIsException($var); + return 1; } + return 0; } - - + //!shows info about different resources, uses customized rendering founctions when needed - function varIsResource($var) { + public function varIsResource($var) + { $this->makeTableHeader('resourceC','resource',1); echo "\n\n"; $restype=get_resource_type($var); - switch($restype) { + switch ($restype) { case 'fbsql result': case 'mssql result': case 'msql query': @@ -396,21 +412,22 @@ class dBug { } echo $this->closeTDRow()."\n"; } - + //!@} - + /*! @name functions for rendering different resources */ //!@{ - + //!shows information about curl easy handles /*!simply iterates through handle info and displays everything which is not converted into false*/ - function varIsCurlEasyResource(&$var) { + public function varIsCurlEasyResource(&$var) + { $this->makeTableHeader('resource','curl easy handle',2); $info=curl_getinfo($var); - foreach($info as $name=>&$piece){ - if($piece){ + foreach ($info as $name=>&$piece) { + if ($piece) { $this->makeTDHeader('resource',$name); //echo $piece.$this->closeTDRow(); $this->checkType($piece); @@ -419,15 +436,16 @@ class dBug { } unset($info); echo ''; - + } //!not implemented yet - function varIsCurlMultiResource(&$var) { - + public function varIsCurlMultiResource(&$var) + { } - + //!if variable is an image/gd resource type - function varIsGDResource(&$var) { + public function varIsGDResource(&$var) + { $this->makeTableHeader('resource','gd',2); $this->makeTDHeader('resource','Width'); $this->checkType(imagesx($var)); @@ -438,44 +456,42 @@ class dBug { $this->makeTDHeader('resource','Colors'); $this->checkType(imageistruecolor($var)?'TrueColor (16 777 216)':imagecolorstotal($var)); echo $this->closeTDRow(); - + $this->makeTDHeader('resource','Image'); - - - + ob_start(); - imagepng($var); - $img = ob_get_clean(); - + imagepng($var); + $img = ob_get_clean(); + echo ''.$this->closeTDRow(); echo ''; } - + //!@} - - + /*! @name database results rendering functions */ //!@{ - + //!renders either PDO or SQLite3 statement objects /*!@returns 1 if the object is DB object, 0 otherwise*/ - function varIsDBObject($var) { + public function varIsDBObject($var) + { $structure=array(); $data=array(); $retres=false; - if($var instanceof SQLite3Result){ + if ($var instanceof \SQLite3Result) { //$var=clone $var; $dbtype=''; $count=$var->numColumns(); - for($i=0;$i<$count;$i++){ + for ($i=0;$i<$count;$i++) { $structure[$i]=array(); $structure[$i][0]=$var->columnName($i); $structure[$i][1]=$var->columnType($i); } $var->reset(); - while($res=$var->fetchArray(SQLITE3_NUM)){ + while ($res=$var->fetchArray(SQLITE3_NUM)) { $data[]=$res; } $var->reset(); @@ -484,11 +500,11 @@ class dBug { $this->renderDBData($dbtype,$structure,$data); $retres=true; } - if($var instanceof PDOStatement){ + if ($var instanceof \PDOStatement) { //$var=clone $var; $count=$var->columnCount(); $col=null; - for($i=0;$i<$count;$i++){ + for ($i=0;$i<$count;$i++) { //$col=$var->getColumnMeta(0); $col=$var->getColumnMeta($i); $structure[$i]=array(); @@ -506,30 +522,32 @@ class dBug { unset($dbtype); unset($data); unset($structure); + return $retres; } - + //!renders database data /*! @param string $objectType type of the db, it is only the name of header now @param array $structure 'header' of the table - columns names and types @param array $data rows of sql request result */ - function renderDBData(&$objectType,&$structure,&$data){ + public function renderDBData(&$objectType,&$structure,&$data) + { $this->makeTableHeader('database',$objectType,count($structure)+1); echo ' '; - foreach($structure as $field) { + foreach ($structure as $field) { echo ''.$field[0].""; } echo ''; - if(empty($data)){ + if (empty($data)) { echo '[empty result]'; }else $i=0; - foreach($data as $row) { + foreach ($data as $row) { echo "\n"; - echo ''.(++$i).''; - for($k=0;$k'.(++$i).''; + for ($k=0;$k'.$fieldrow."\n"; } @@ -537,23 +555,24 @@ class dBug { } echo ''; } - + //!renders database resource (fetch result) into table or ... smth else - function varIsDBResource($var,$db='mysql') { + public function varIsDBResource($var,$db='mysql') + { if($db == 'pgsql') $db = 'pg'; if($db == 'sybase-db' || $db == 'sybase-ct') $db = 'sybase'; - $arrFields = array('name','type','flags'); + $arrFields = array('name','type','flags'); $numrows=call_user_func($db.'_num_rows',$var); $numfields=call_user_func($db.'_num_fields',$var); $this->makeTableHeader('database',$db.' result',$numfields+1); echo ' '; - for($i=0;$i<$numfields;$i++) { + for ($i=0;$i<$numfields;$i++) { $field_header = ''; - for($j=0; $j'.$field_name.''; } echo ''; - for($i=0;$i<$numrows;$i++) { + for ($i=0;$i<$numrows;$i++) { $row=call_user_func($db.'_fetch_array',$var,constant(strtoupper($db).'_ASSOC')); echo "\n"; - echo ''.($i+1).''; - for($k=0;$k<$numfields;$k++) { + echo ''.($i+1).''; + for ($k=0;$k<$numfields;$k++) { $tempField=$field[$k]->name; $fieldrow=$row[($field[$k]->name)]; $fieldrow=($fieldrow=='') ? '[empty string]' : $fieldrow; @@ -582,13 +601,12 @@ class dBug { call_user_func($db.'_data_seek',$var,0); } //!@} - - + /*! @name other special kinds of objects rendering functionality */ //!@{ - + //!array of properties of every exception to be rendered first static $exceptionMainProps=array('message','code','file','line'); //!array of properties of Exception of not to be rendered @@ -596,26 +614,27 @@ class dBug { //'xdebug_message', 'trace' ); - + //!function used to render exceptions /*! Renders exceptions : at first basic fields, then custom fields. Custom private and protected fields are rendered if reflection api is available */ - function varIsException(&$var) { + public function varIsException(&$var) + { $code=$var->getCode(); $this->makeTableHeader('Exception',get_class($var).' :: '.$code); - foreach(static::$exceptionMainProps as &$pname) { + foreach (static::$exceptionMainProps as &$pname) { $this->makeTDHeader('Exception',$pname); $this->checkType($var->{'get'.ucfirst($pname)}()); echo $this->closeTDRow(); } unset($pname); echo ''; - if(extension_loaded('Reflection')){ - $refl=new ReflectionObject($var); + if (extension_loaded('Reflection')) { + $refl=new \ReflectionObject($var); $props=$refl->getProperties(ReflectionProperty::IS_PROTECTED|ReflectionProperty::IS_PRIVATE); - foreach($props as &$prop) { + foreach ($props as &$prop) { $pname=$prop->getName(); if(in_array($pname,static::$exceptionMainProps)||in_array($pname,static::$exceptionExcludedProps))continue; $this->makeTDHeader('Exception',$pname); @@ -625,76 +644,79 @@ class dBug { echo $this->closeTDRow(); } } - - foreach($var as $key=>&$value) { + + foreach ($var as $key=>&$value) { if($key=='xdebug_message')continue; $this->makeTDHeader('Exception',$key); $this->checkType($value); echo $this->closeTDRow(); } - + echo ''; } - + //!@} - - - + /*! @name xml rendering functions */ //!@{ - + //!if variable is an xml type //!remember, that you must force type to xml to use this - function varIsXml($var) { + public function varIsXml($var) + { $this->varIsXmlResource($var); } - + //!if variable is an xml resource type - function varIsXmlResource($var) { + public function varIsXmlResource($var) + { $xml_parser=xml_parser_create(); - xml_parser_set_option($xml_parser,XML_OPTION_CASE_FOLDING,0); - xml_set_element_handler($xml_parser,array(&$this,'xmlStartElement'),array(&$this,'xmlEndElement')); + xml_parser_set_option($xml_parser,XML_OPTION_CASE_FOLDING,0); + xml_set_element_handler($xml_parser,array(&$this,'xmlStartElement'),array(&$this,'xmlEndElement')); xml_set_character_data_handler($xml_parser,array(&$this,'xmlCharacterData')); - xml_set_default_handler($xml_parser,array(&$this,'xmlDefaultHandler')); - + xml_set_default_handler($xml_parser,array(&$this,'xmlDefaultHandler')); + $this->makeTableHeader('xml','xml document',2); $this->makeTDHeader('xml','xmlRoot'); - + //attempt to open xml file $bFile=(!($fp=@fopen($var,'r'))) ? false : true; - + //read xml file - if($bFile) { + if ($bFile) { while($data=str_replace("\n",'',fread($fp,4096))) $this->xmlParse($xml_parser,$data,feof($fp)); } //if xml is not a file, attempt to read it as a string else { - if(!is_string($var)) { + if (!is_string($var)) { echo $this->error('xml').$this->closeTDRow()."\n"; + return; } $data=$var; $this->xmlParse($xml_parser,$data,1); } - + echo $this->closeTDRow()."\n"; - + } - + //!parses xml - function xmlParse($xml_parser,$data,$bFinal) { - if (!xml_parse($xml_parser,$data,$bFinal)) { - die(sprintf("XML error: %s at line %d\n", - xml_error_string(xml_get_error_code($xml_parser)), + public function xmlParse($xml_parser,$data,$bFinal) + { + if (!xml_parse($xml_parser,$data,$bFinal)) { + throw new \Exception(sprintf("dBug XML error: %s at line %d\n", + xml_error_string(xml_get_error_code($xml_parser)), xml_get_current_line_number($xml_parser))); } } - + //!xml: inititiated when a start tag is encountered - function xmlStartElement($parser,$name,$attribs) { + public function xmlStartElement($parser,$name,$attribs) + { $this->xmlAttrib[$this->xmlCount]=$attribs; $this->xmlName[$this->xmlCount]=$name; $this->xmlSData[$this->xmlCount]='$this->makeTableHeader("xml","xml element",2);'; @@ -707,11 +729,12 @@ class dBug { $this->xmlSData[$this->xmlCount].='echo " ";'; $this->xmlSData[$this->xmlCount].='echo $this->closeTDRow();'; $this->xmlCount++; - } - + } + //!xml: initiated when an end tag is encountered - function xmlEndElement($parser,$name) { - for($i=0;$i<$this->xmlCount;$i++) { + public function xmlEndElement($parser,$name) + { + for ($i=0;$i<$this->xmlCount;$i++) { eval($this->xmlSData[$i]); $this->makeTDHeader("xml","xmlText"); echo (!empty($this->xmlCData[$i])) ? $this->xmlCData[$i] : " "; @@ -725,21 +748,23 @@ class dBug { echo $this->closeTDRow(); echo ''; $this->xmlCount=0; - } - + } + //!xml: initiated when text between tags is encountered - function xmlCharacterData($parser,$data) { + public function xmlCharacterData($parser,$data) + { $count=$this->xmlCount-1; if(!empty($this->xmlCData[$count])) $this->xmlCData[$count].=$data; else $this->xmlCData[$count]=$data; - } - + } + //!@} - + //!xml: initiated when a comment or other miscellaneous texts is encountered - function xmlDefaultHandler($parser,$data) { + public function xmlDefaultHandler($parser,$data) + { //strip '' off comments $data=str_replace(array("<!--","-->"),"",htmlspecialchars($data)); $count=$this->xmlCount-1; @@ -748,59 +773,65 @@ class dBug { else $this->xmlDData[$count]=$data; } - + //! adds needed JS and CSS sources to page - static function initJSandCSS() { + public static function initJSandCSS() + { echo << /* code modified from ColdFusion's cfdump code */ - function dBug_toggleRow(source) { + function dBug_toggleRow(source) + { var target = (document.all) ? source.parentElement.cells[1] : source.parentNode.lastChild; dBug_toggleTarget(target,dBug_toggleSource(source)); } - - function dBug_toggleSource(source) { + + function dBug_toggleSource(source) + { if (source.style.fontStyle=='italic') { source.style.fontStyle='normal'; source.title='click to collapse'; + return 'open'; } else { source.style.fontStyle='italic'; source.title='click to expand'; + return 'closed'; } } - - function dBug_toggleTarget(target,switchToState) { + + function dBug_toggleTarget(target,switchToState) + { target.style.display = (switchToState=='open') ? '' : 'none'; } - - function dBug_toggleTable(source) { + + function dBug_toggleTable(source) + { var switchToState=dBug_toggleSource(source); - if(document.all) { + if (document.all) { var table=source.parentElement.parentElement; - for(var i=1;i - + SCRIPTS; } -} \ No newline at end of file +} diff --git a/tests.php b/tests.php index 86c6a30..e2a6284 100644 --- a/tests.php +++ b/tests.php @@ -1,5 +1,10 @@ -edible = $edible; - $this->color = $color; - } + var $edible; + var $color; + function Vegetable($edible, $color="green") { + $this->edible = $edible; + $this->color = $color; + } - function is_edible() { - return $this->edible; - } + function is_edible() { + return $this->edible; + } - function what_color() { - return $this->color; - } + function what_color() { + return $this->color; + } } new dBug(new Vegetable("spinach")); - $a=curl_init("http://github.com/"); - new dBug($a); - - class myExc extends Exception{ + $a=curl_init("https://github.com/"); + new dBug($a); + //curl_exec($a); + //new dBug($a); + + class myExc extends \Exception{ private $priv="PREVED"; protected $ololo="trololol"; public $num=0; @@ -58,12 +65,12 @@ }; try{ throw new myExc("MedVed"); - }catch(Exception $e){ + }catch(\Exception $e){ new dBug($e); } try{ - throw new Exception("hahahahaha"); - }catch(Exception $e){ + throw new \Exception("hahahahaha"); + }catch(\Exception $e){ new dBug($e); }