Skip to content

Commit

Permalink
improve demos
Browse files Browse the repository at this point in the history
  • Loading branch information
rodber committed Mar 15, 2024
1 parent d2a4fc0 commit f48555f
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 20 deletions.
21 changes: 21 additions & 0 deletions demo/autoload.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

/*
* This file is part of Chevere.
*
* (c) Rodolfo Berrios <rodolfo@chevere.org>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

foreach (['/../', '/../../../../'] as $path) {
$autoload = __DIR__ . $path . 'vendor/autoload.php';
if (stream_resolve_include_path($autoload)) {
require $autoload;

break;
}
}
16 changes: 4 additions & 12 deletions demo/error-handling.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,7 @@
use function Chevere\Writer\streamFor;
use function Chevere\xrDebug\PHP\registerThrowableHandler;

foreach (['/../', '/../../../../'] as $path) {
$autoload = __DIR__ . $path . 'vendor/autoload.php';
if (stream_resolve_include_path($autoload)) {
require $autoload;

break;
}
}
require 'autoload.php';

new WritersInstance(
(new Writers())
Expand All @@ -46,10 +39,9 @@
register_shutdown_function(
ThrowableHandler::SHUTDOWN_ERROR_AS_EXCEPTION
);
// Uncomment to also use the console handler
// set_exception_handler(
// ThrowableHandler::CONSOLE
// );
set_exception_handler(
ThrowableHandler::CONSOLE
);
registerThrowableHandler(true);

throw new RuntimeException(
Expand Down
50 changes: 50 additions & 0 deletions demo/vdd.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

/*
* This file is part of Chevere.
*
* (c) Rodolfo Berrios <rodolfo@chevere.org>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

require 'autoload.php';

/**
* Mimic xdebug var_dump example to showcase Chevere's VarDump.
* https://xdebug.org/docs/develop#improved_var_dump
*/

class test
{
public self $pub;

protected $prot = 42;

private $priv = true;

public function __construct()
{
$this->pub = $this;
}
}

$array = [
'one' => 'a somewhat long string!',
'two' => [
'two.one' => [
'two.one.zero' => 210,
'two.one.one' => [
'two.one.one.zero' => M_PI,
'two.one.one.one' => 2.7,
],
],
],
'three' => new test(),
'four' => range(0, 5),
];

vdd($array);
10 changes: 2 additions & 8 deletions demo/welcome.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,8 @@

declare(strict_types=1);

foreach (['/../', '/../../../../'] as $path) {
$autoload = __DIR__ . $path . 'vendor/autoload.php';
if (stream_resolve_include_path($autoload)) {
require $autoload;
require_once 'autoload.php';

break;
}
}
xrr('πŸ‘‹ Welcome to xrDebug!');
xri()->pause();
xr(
Expand Down Expand Up @@ -53,7 +47,7 @@
);
sleep(5);
xr(
πŸ‘‡: 'Copy caller file path by clicking on ' . basename(__FILE__) . ':' . (string) (__LINE__ + 2) . ' here below.',
πŸ‘‡: 'Open caller file path by clicking on ' . basename(__FILE__) . ':' . (string) (__LINE__ - 1) . ' here below.',
t: 'how-to',
e: 'πŸ“Ž'
);
Expand Down

0 comments on commit f48555f

Please sign in to comment.