Skip to content

Commit

Permalink
v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
alddesign committed Jul 19, 2024
1 parent 8720c92 commit 6574b71
Show file tree
Hide file tree
Showing 23 changed files with 1,507 additions and 157 deletions.
1 change: 1 addition & 0 deletions .vscode/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Deny from all
14 changes: 14 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 9003
}
]
}
44 changes: 38 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,47 @@
# php-xout
A more readable implementation of PHP´s var_dump() function
A more readable, syntax highlighted implementation of PHPs `var_dump()` or `print_r()` function.
*Compatible with all PHP versions **back to 5.4***

## Installation
### Via Composer
`composer require alddesign/php-xout`
### Manual
Downlaod the package and load `xout.php`:
```php
require_once 'xout.php'
```

## Usage
```php
require('xout.php');
//code before...
$array =
[
'cars' => ['audi','bmw','volkswagen'],
'settings' => (object)
[
'drive' => true,
'disable_car' =>
function(){}
],
'value' => 220.25,
'active' => null
];

$var = ['cars' => ['audi','bmw'], 'nothing' => (object)['name' => 'Mario', 'age' => 34]];
//Call xout
Xout::xout($array);

//Or use the shorthand function:
xout($var);
```
This will output the contents of <code>$var</code> to the browser and call <code>die();</code> (Unless you specify <code>$dontDie = true</code>)

The output will look like:
The output will look like this:
![output](<test/output.png>)

## Remarks
### Parameters
- **value**: The expression to output
- **return** (bool): If set to `true` the resulting html is being returned insted of echoing it. Default: `false`
- **dontDie** (bool): If set to `true` the script will not terminated. When `return` is set to `true`, this parameter has no effect. Default: `false`

![output](<out.png>)
### Customization
In `xout.php` you can change many options like font, color, brace style,...
20 changes: 20 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "alddesign/php-xout",
"description": "A more readable implementation of PHPs var_dump() function",
"version": "1.0.0",
"support": {
"issues": "https://github.com/ankane/alddesign/php-xout/issues",
"source": "https://github.com/ankane/alddesign/php-xout"
},
"authors": [
{
"name": "alddesign"
}
],
"autoload": {
"files": ["xout.php"]
},
"require": {
"php": ">= 5.4"
}
}
20 changes: 20 additions & 0 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file removed out.png
Binary file not shown.
40 changes: 0 additions & 40 deletions test.php

This file was deleted.

Binary file added test/output.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions test/test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php
require '../xout.php';

class Train
{
public $description = 'Shinkansen';
public function activate(){}
}

$something =
[
'fruits' => ['apple', 'banana', 'strawberry'],
'person' =>
[
'name' => 'Mario',
'age' => 34,
'rating' => 7.34,
'registered' => false,
'picture' => null
],
'car' => (object)
[
'brand' => 'BWM',
'hp' => 220.25,
'drive' => function(){}
],
'train object' => new Train(),
'emtpy array' => [],
'empty object' => (object)[],
'nested array' => [[[[]]]],
];

xout($something);
25 changes: 25 additions & 0 deletions vendor/autoload.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

// autoload.php @generated by Composer

if (PHP_VERSION_ID < 50600) {
if (!headers_sent()) {
header('HTTP/1.1 500 Internal Server Error');
}
$err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
if (!ini_get('display_errors')) {
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
fwrite(STDERR, $err);
} elseif (!headers_sent()) {
echo $err;
}
}
trigger_error(
$err,
E_USER_ERROR
);
}

require_once __DIR__ . '/composer/autoload_real.php';

return ComposerAutoloaderInit0ea57707cf328774930a8944662deffc::getLoader();
Loading

0 comments on commit 6574b71

Please sign in to comment.