File tree Expand file tree Collapse file tree 5 files changed +100
-0
lines changed
Expand file tree Collapse file tree 5 files changed +100
-0
lines changed Original file line number Diff line number Diff line change 1+ .DS_STORE
2+
3+ /vendor /
Original file line number Diff line number Diff line change 1+ = Debug
2+
3+ A PHP libary for debugging.
4+
5+
6+ == Installation
7+ You can install the libary with `composer`:
8+
9+ [source,zsh]
10+ ----
11+ composer require devidw/debug
12+ ----
13+
14+
15+ == Usage
16+ [source,php]
17+ ----
18+ require_once __DIR__ . '/vendor/autoload.php';
19+
20+ use DevidW\Debug\Debug;
21+
22+ Debug::dump($var);
23+ ----
24+
25+
26+ ***
27+
28+
29+ Syntax highlighting is done using https://highlightjs.org/[highlight.js] and the _Atom One Dark_ Theme.
Original file line number Diff line number Diff line change 1+ {
2+ "name" : " devidw/debug" ,
3+ "description" : " A PHP libary for debugging." ,
4+ "type" : " library" ,
5+ "license" : " MIT" ,
6+ "autoload" : {
7+ "psr-4" : {
8+ "Devidw\\ Debug\\ " : " src/"
9+ }
10+ },
11+ "authors" : [
12+ {
13+ "name" : " David Wolf" ,
14+ "email" : " david@wolf.gdn"
15+ }
16+ ],
17+ "require" : {}
18+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Devidw \Debug ;
4+
5+ /**
6+ * Class Debug
7+ *
8+ * @package Devidw\Debug
9+ * @version 1.0.0
10+ */
11+ class Debug
12+ {
13+ /**
14+ * Dump the given variable
15+ *
16+ * @since 1.0.0
17+ *
18+ * @param mixed $var The variable to dump
19+ * @param bool $die Whether to die after dumping
20+ *
21+ * @return void
22+ */
23+ public static function dump (mixed $ var , $ die = true ): void
24+ {
25+ $ dump = var_export ($ var , true );
26+
27+ echo <<<HTML
28+ <pre><code class="language-php"> {$ dump }</code></pre>
29+ <link rel="stylesheet" href="https://highlightjs.org/static/demo/styles/atom-one-dark.css">
30+ <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.4.0/highlight.min.js"></script>
31+ <script>hljs.highlightAll()</script>
32+ HTML ;
33+
34+ if ($ die ) {
35+ die;
36+ }
37+ }
38+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ require_once dirname (__DIR__ ) . '/vendor/autoload.php ' ;
4+
5+
6+ use Devidw \Debug \Debug ;
7+
8+ Debug::dump ([
9+ 'foo ' => 'bar ' ,
10+ 'object ' => new stdClass (),
11+ 'init ' => ini_get_all (),
12+ ]);
You can’t perform that action at this time.
0 commit comments