Skip to content

Commit 3a8dca8

Browse files
committed
πŸš€ initial commit
0 parents  commit 3a8dca8

File tree

7 files changed

+152
-0
lines changed

7 files changed

+152
-0
lines changed

β€Ž.editorconfig

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
indent_style = space
8+
indent_size = 4
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false
13+
14+
[*.yml]
15+
indent_style = space
16+
indent_size = 2

β€Ž.gitignore

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

β€ŽLICENSE

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
BSD 3-Clause License
2+
3+
Copyright (c) 2021-present, Mhammed Talhaouy
4+
5+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6+
7+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
8+
9+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
10+
11+
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
12+
13+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

β€ŽREADME.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# dd
2+
3+
This library will add the `dd` and `dump` helpers to your PHP application.
4+
5+
⚑️ Install
6+
7+
Run:
8+
9+
```sh
10+
composer require tal7aouy/dd
11+
```
12+
13+
βœ… Usage
14+
15+
```php
16+
$arr = ['a'=>'a','b'=>b];
17+
dd($arr);
18+
// or
19+
dump($arr);
20+
```
21+
πŸ€“ output:
22+
```json
23+
^ array:2 [β–Ό
24+
"a" => "a"
25+
"b" => "b"
26+
]
27+
```
28+
29+
30+
πŸš€ For Laravel
31+
32+
[Laravel](http://laravel.com) already have the `dd` function in its helpers.
33+
The `dd` function from this package is equal to the one in Laravel.
34+
35+
36+
**dd** was created by **[tal7aouy](https://github.com/tal7aouy)** under the **[BSD-3-Clause](https://opensource.org/licenses/BSD-3-Clause)**.

β€Žcomposer.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"name": "tal7aouy/dd",
3+
"type": "library",
4+
"description": "This package will add the `dd` and `dump` helpers to your PHP application.",
5+
"keywords": [
6+
"dd",
7+
"dump",
8+
"debuger",
9+
"var_dump",
10+
"utils",
11+
"debug",
12+
"vardumper"
13+
],
14+
"homepage": "https://github.com/tal7aouy/dd",
15+
"license": "BSD-3-Clause",
16+
"authors": [
17+
{
18+
"name": "Mhammed Talhaouy",
19+
"email": "tal7aouy@gmail.com",
20+
"role": "developer"
21+
}
22+
],
23+
"require": {
24+
"php": "^8.1",
25+
"symfony/var-dumper": "*"
26+
},
27+
"autoload": {
28+
"files": [
29+
"src/helper.php"
30+
]
31+
},
32+
"support": {
33+
"issues": "https://github.com/tal7aouyy/dd/issues",
34+
"source": "https://github.com/tal7aouy/dd"
35+
}
36+
}

β€Žindex.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
require __DIR__ . "/vendor/autoload.php";
4+
$arr = ['a' => 'a', 'b' => 'b'];
5+
dump($arr);

β€Žsrc/helper.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
/**
4+
* tal7aouy <tal7aouy@gmail.com>
5+
*
6+
* (c) copyright 2022
7+
*/
8+
9+
use Symfony\Component\VarDumper\Dumper\CliDumper;
10+
use Symfony\Component\VarDumper\Cloner\VarCloner;
11+
12+
if (!function_exists('dd')) {
13+
/**
14+
* Dump the passed variables and end the script.
15+
*
16+
* @param mixed
17+
* @return void
18+
*/
19+
function dd()
20+
{
21+
call_user_func_array('dump', func_get_args());
22+
23+
die(1);
24+
}
25+
}
26+
27+
if (!function_exists('dump')) {
28+
/**
29+
* Dump the passed variables without end the script.
30+
*
31+
* @param mixed
32+
* @return void
33+
*/
34+
function dump($value)
35+
{
36+
if (class_exists(CliDumper::class)) {
37+
$dumper = 'cli' === PHP_SAPI ? new CliDumper : new HtmlDumper;
38+
39+
$dumper->dump((new VarCloner)->cloneVar($value));
40+
} else {
41+
var_dump($value);
42+
}
43+
}
44+
}

0 commit comments

Comments
Β (0)