diff --git a/.gitignore b/.gitignore index 17e2cb3..ebdb66f 100644 --- a/.gitignore +++ b/.gitignore @@ -4,5 +4,5 @@ /composer.lock /*.log /null -/.htaccess -/.user.ini +/example/.htaccess +/example/.user.ini diff --git a/composer.json b/composer.json index e7abca7..ab86fb5 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,8 @@ "ArcanisGK\\PhpDevelopmentTool\\": "src/" }, "files": [ - "src/phpDevToolInitialization.php" + "src/Init/phpDevToolInitialization.php", + "src/Init/phpExposeData.php" ] }, "authors": [ diff --git a/example/dumper.php b/example/dumper.php index b3191d4..0187687 100644 --- a/example/dumper.php +++ b/example/dumper.php @@ -19,4 +19,6 @@ require_once __DIR__ . "/../vendor/autoload.php"; -dop(['test' => 'Hello World', 2022]); \ No newline at end of file +sd(['test' => 'Hello World', 2022]); + +sda(['test' => 'Hello World', 2022]); \ No newline at end of file diff --git a/example/test/error_log.log b/example/test/error_log.log new file mode 100644 index 0000000..cc41951 --- /dev/null +++ b/example/test/error_log.log @@ -0,0 +1,2 @@ +1655576398 2022-06-18 13:19:58 Test Trace: No backtrace data in the ExceptionHandler. +1655576399 2022-06-18 13:19:59 Use of undefined constant wath - assumed 'wath' (this will throw an Error in a future version of PHP) Trace: No backtrace data in the ErrorHandler. diff --git a/src/ExposeData/ExposeEngine.php b/src/ExposeData/ExposeEngine.php new file mode 100644 index 0000000..1594ba2 --- /dev/null +++ b/src/ExposeData/ExposeEngine.php @@ -0,0 +1,153 @@ +highlight = $options['highlight']; + } + if (isset($options['end'])) { + $this->end = $options['end']; + } + } + $this->options = $options; + } + + /** + * @param $var + * @return void + */ + + public function varDump($var): void + { + $this->clean(); + if ($this->highlight) { + $this->Explain($var); + } else { + $this->capture($var); + } + $this->output(); + if ($this->end) { + die; + } + } + + /** + * @return void + */ + + private function clean(): void + { + if (ob_get_contents() || ob_get_length()) { + ob_end_clean(); + flush(); + } + } + + /** + * @param $var + * @return void + */ + + private function Explain($var) + { + echo 'Under Development
'; + $this->capture($var); + } + + /** + * @param $var + * @return void + */ + + private function capture($var): void + { + ob_start(); + var_dump($var); + $this->data = ob_get_contents(); + ob_end_clean(); + } + + /** + * @return void + */ + + private function output(): void + { + echo '
' . $this->data . '
'; + } +} diff --git a/src/phpDevToolInitialization.php b/src/Init/phpDevToolInitialization.php similarity index 93% rename from src/phpDevToolInitialization.php rename to src/Init/phpDevToolInitialization.php index 0e14af5..9afd928 100644 --- a/src/phpDevToolInitialization.php +++ b/src/Init/phpDevToolInitialization.php @@ -9,7 +9,7 @@ * @author Walter Nuñez (arcanisgk/original founder) * @email icarosnet@gmail.com * @copyright 2020 - 2022 Walter Nuñez/Icaros Net S.A. - * @license For the full copyright and licence information, please view the LICENSE + * @license For the full copyright and licence information, please view the LICENCE * @note This program is distributed in the hope that it will be useful * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. @@ -17,7 +17,10 @@ declare(strict_types=1); -namespace ArcanisGK\PhpDevelopmentTool; +namespace ArcanisGK\PhpDevelopmentTool\Init; + +use ArcanisGK\PhpDevelopmentTool\BugCatcher; +use ArcanisGK\PhpDevelopmentTool\WebCLIDetector; /** * phpDevToolInitialization Class. @@ -66,7 +69,7 @@ public function run() $path = dirname(__DIR__) . '/src/'; - $directive_reader = file_get_contents(dirname(__DIR__) . '/src/directive/php.txt'); + $directive_reader = file_get_contents(dirname(__DIR__) . '/../src/directive/php.txt'); $directive_explained = str_replace("{path}", $path, $directive_reader); @@ -102,9 +105,3 @@ public function run() BugCatcher::getInstance(['dir_log' => '/']); -function dop($var) -{ - echo '
';
-    echo var_export($var);
-    echo '
'; -} diff --git a/src/Init/phpExposeData.php b/src/Init/phpExposeData.php new file mode 100644 index 0000000..4966393 --- /dev/null +++ b/src/Init/phpExposeData.php @@ -0,0 +1,46 @@ + false, 'end' => false])->varDump($var); + } +} + +/** + * @param ...$data + * @return void + * @noinspection PhpUnused + */ + +function sda(...$data) +{ + foreach ($data as $var) { + ExposeEngine::getInstance(['highlight' => true])->varDump($var); + } +}