Skip to content

Instantly share code, notes, and snippets.

@dib258
Last active June 7, 2024 23:34
Show Gist options
  • Save dib258/2a7a3d1c3f5f72b9210da2f0359b0b86 to your computer and use it in GitHub Desktop.
Save dib258/2a7a3d1c3f5f72b9210da2f0359b0b86 to your computer and use it in GitHub Desktop.
Special Template Color for the dd method in Laravel
<?php
namespace Illuminate\Support\Debug;
use Symfony\Component\VarDumper\Cloner\VarCloner;
use Symfony\Component\VarDumper\Dumper\CliDumper;
class Dumper
{
/**
* Dump a value with elegance.
*
* @param mixed $value
* @return void
*/
public function dump($value)
{
if (class_exists(CliDumper::class)) {
$dumper = 'cli' === PHP_SAPI ? new CliDumper : new HtmlDumper;
echo '<body style="background-color : #2b2a27;">';
$dumper->dump((new VarCloner)->cloneVar($value));
} else {
var_dump($value);
}
}
}
<?php
namespace Illuminate\Support\Debug;
use Symfony\Component\VarDumper\Dumper\HtmlDumper as SymfonyHtmlDumper;
class HtmlDumper extends SymfonyHtmlDumper
{
/**
* Colour definitions for output.
*
* @var array
*/
protected $styles = [
'default' => 'background-color:#2b2a27; color:#d0cfcd; line-height:1.2em; font-weight:normal; font:14px Menlo, Consolas, monospace; word-wrap: break-word; white-space: pre-wrap; position:relative; z-index:100000',
'num' => 'color:#FF5D38',
'const' => 'color:#BBD8CE',
'str' => 'color:#FF5D38',
'cchr' => 'color:#222',
'note' => 'color:#BBD8CE',
'ref' => 'color:#FFF3AA',
'public' => 'color:#26A6A6',
'protected' => 'color:#26A6A6',
'private' => 'color:#26A6A6',
'meta' => 'color:#b729d9',
'key' => 'color:#BCD42A',
'index' => 'color:#BCD42A',
];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment