diff --git a/examples/example_simple.php b/examples/example_simple.php index 8fbd1ca..f47e461 100644 --- a/examples/example_simple.php +++ b/examples/example_simple.php @@ -2,7 +2,7 @@ $isDev = true; -require_once "../fastDbgPHP.class.php"; +require_once "./fastDbgPHP.class.php"; // FastDbgPHP Configuration FastDbgPHP::setDevelopmentMode($isDev); @@ -23,8 +23,6 @@ "age" => 18, "from" => "Brazil" ]; -$i = new DateTime(); -fdbg($a, $b, $c, $d, $e, $f, $g, $h, $i); +fdbg($a, $b, $c, $d, $e, $f, $g, $h); -fdbg(); diff --git a/examples/example_standard.php b/examples/example_standard.php index f1dee7e..eecbd49 100644 --- a/examples/example_standard.php +++ b/examples/example_standard.php @@ -3,7 +3,7 @@ $start_time = microtime(true); $isDev = true; -require_once "../fastDbgPHP.class.php"; +require_once "./fastDbgPHP.class.php"; // FastDbgPHP Configuration FastDbgPHP::setDevelopmentMode($isDev); @@ -12,7 +12,8 @@ FastDbgPHP::setInicialTime($start_time); FastDbgPHP::setProjectName("Project Example"); FastDbgPHP::setDefaultValues(["##GET", "##POST", "##SERVER"]); -FastDbgPHP::setIsExit(false); +FastDbgPHP::setIsExit(true); +// FastDbgPHP::setclickToCopy(false); FastDbgPHP::setStyles([ "header" => "color: #404040; font-size: 18px; @@ -44,8 +45,10 @@ public function __construct( "from" => "Brazil" ]; $i = new Person("Maria", 7); +$j = new DateTime(); +$k = " Espaços em branco antes e depois "; -fdbg($a, $b, $c, $d, $e, $f, $g, $h, $i); - +fdbg($a, $b, $c, $d, $e, $f, $g, $h, $i, $j, $k); +fdbg('##GETENV'); fdbg(); diff --git a/fastDbgPHP.class.php b/fastDbgPHP.class.php index a5130ed..7d08a8f 100644 --- a/fastDbgPHP.class.php +++ b/fastDbgPHP.class.php @@ -45,7 +45,7 @@ class FastDbgPHP text-align: right; padding: 5px 10px; word-break: break-word;', - 'arrays' => 'border: 1px solid #DCDCDC; + 'arraysKey' => 'border: 1px solid #DCDCDC; border-radius: 5px; background-color: #EEE; font-size: 12px; @@ -60,6 +60,11 @@ class FastDbgPHP text-align: left; padding: 5px 10px; margin: 1px; + word-break: break-word;', + 'ArrayDetails' => 'color: #707070; + font-size: 10px; + font-style: italic; + text-align: right; word-break: break-word;' ]; @@ -108,7 +113,7 @@ static public function setclickToCopy(bool $clickToCopy): void * * @param mixed ... $values * ##TRACE - Show traceback - * ##GET, ##POST, ##SERVER, ##FILES, ##COOKIE, ##SESSION, ##REQUEST, ##ENV - Show global var + * ##GET, ##POST, ##SERVER, ##FILES, ##COOKIE, ##SESSION, ##REQUEST, ##ENV, ##GETENV - Show global var * ##EXIT - Finish the code * ##TIME */ @@ -137,7 +142,7 @@ static public function fdbg(mixed ...$values): void $hasexit = static::$isExit; - echo '
'; + echo '
'; foreach ($values as $value) { if (is_null($value)) { $type = get_debug_type($value); @@ -173,6 +178,8 @@ static public function fdbg(mixed ...$values): void } } elseif ($value == "##REQUEST") { static::generateDetailRow("πŸ”— Requests", $_REQUEST); + } elseif ($value == "##GETENV") { + static::generateDetailRow("πŸ”— Getenv", getenv()); } elseif ($value == "##ENV") { static::generateDetailRow("🏠 Environment", $_ENV); } elseif ($value == "##EXIT") { @@ -187,17 +194,17 @@ static public function fdbg(mixed ...$values): void $Mocno = 'Mocno'; $fastDbgPHP = 'Fast Debug PHP'; - - $creditMsg = "$fastDbgPHP developed by $LePampim and $Mocno. "; if($hasexit) $creditMsg .= "[❌ exited] "; if (static::$clickToCopy) $creditMsg .= "[πŸ“‘ click to copy] "; - static::generateRowCredit($creditMsg); + echo '
'; + echo '
'.$creditMsg.'
'; echo "
"; + echo '
'; if ($hasexit) exit; @@ -206,84 +213,94 @@ static public function fdbg(mixed ...$values): void static private function generateDetailRow(string $info, mixed $description) { - if (is_string($description)) - $info .= " [" . strlen($description) . "]"; - elseif (is_array($description)) + if (is_array($description)) $info .= " [" . count($description) . "]"; echo '
'.$info.'
'; echo '
'; if (is_string($description)) { - static::generateSimpleTable($description); + static::generateContent($description, static::$styles['descriptionArrays'], true, true); } elseif (is_array($description)) { if ($description) { static::generateArrayTable((array) $description); } else - static::generateSimpleTable("Empty"); + static::generateContent("Empty", static::$styles['descriptionArrays'], true, false); } elseif (is_object($description)) static::generateArrayTable((array) $description); else - static::generateSimpleTable($description); + static::generateContent($description, static::$styles['descriptionArrays'], true); echo '
'; } - static private function generateRow(string $info, mixed $description) - { - static::generateContent($info, static::$styles['info']); - echo '
'; - static::generateSimpleTable($description); - echo '
'; - } - static private function generateTracebackRow(string $info) - { - static::generateContent($info, static::$styles['info']); - echo '
'; - echo '
";
-        debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
-        echo '
'; - } - static private function generateRowCredit(mixed $description) - { - static::generateContent("", static::$styles['info']); - static::generateContent($description, static::$styles['descriptionCredit']); - } - - static private function generateSimpleTable($value) - { - static::generateContent($value, static::$styles['descriptionArrays'], true); - } - static private function generateArrayTable(array $arrays) { echo '
'; foreach ($arrays as $key => $value) { - static::generateContent($key, static::$styles['arrays'], true); + static::generateContent($key, static::$styles['arraysKey'], true); if (is_string($value)) - static::generateContent($value, static::$styles['descriptionArrays'], true); + static::generateContent($value, static::$styles['descriptionArrays'], true, true); else { if (is_array($value)) { if ($value) static::generateArrayTable((array) $value); else - static::generateContent("", static::$styles['descriptionArrays'], true); + static::generateContent("", static::$styles['descriptionArrays'], true, true); } elseif (is_object($value)) { static::generateArrayTable((array) $value); } else { - static::generateContent($value, static::$styles['descriptionArrays'], true); + static::generateContent($value, static::$styles['descriptionArrays'], true, true); } } } echo '
'; } - static private function generateContent(string $value, string $style, bool $copy = false) { - if ($copy and static::$clickToCopy) { + static private function generateRow(string $info, mixed $description) + { + echo '
'.$info.'
'; + echo '
'; + static::generateContent($description, static::$styles['descriptionArrays'], true); + echo '
'; + } + + static private function generateTracebackRow(string $info) + { + static::generateContent($info, static::$styles['info'], false); + echo '
'; + echo '
";
+        debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
+        echo '
'; + } + + static private function generateContent(string $value, string $style, bool $copy = false, bool $len = false) { + + if (trim($value) != $value) + $column = "20px"; + else + $column = ""; + + echo "
"; + + if ($copy and static::$clickToCopy) + { $id = 'idCopy'.static::$buttomId += 1; - echo '
$value
"; - } else - echo '
$value
"; + echo "
$value
"; + } else + echo '
$value
"; + + if (trim($value) != $value and $style != static::$styles['descriptionCredit']) + echo '
🟧
'; + + if ($len) + echo '
'.strlen($value).'
'; + else + echo '
'; + + echo '
'; + + } static private function scriptCopyText (){ @@ -301,9 +318,5 @@ function copyTextFdbg(copyId) { } "; } - static private function CSSSSSSS (){ - echo ""; - } + }