Skip to content

Commit 33905b0

Browse files
committed
Init
0 parents  commit 33905b0

File tree

5 files changed

+100
-0
lines changed

5 files changed

+100
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.DS_STORE
2+
3+
/vendor/

README.adoc

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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.

composer.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
}

src/Debug.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
}

tests/test.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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+
]);

0 commit comments

Comments
 (0)