Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Added new entry for changing the theme in the HtmlDumper #10745

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added _images/components/var_dumper/10-light-theme.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 43 additions & 0 deletions components/var_dumper.rst
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,49 @@ then its dump representation::

.. image:: /_images/components/var_dumper/09-cut.png

Changing the output color of HtmlDumper
----------------------------------------

The :class:`Symfony\\Component\\VarDumper\\Dumper\\HtmlDumper` class added a new :method:`Symfony\\Component\\VarDumper\\Dumper\\HtmlDumper::setTheme` method. Now you can use both ``'dark'`` and ``'light'`` options.

Example::

require __DIR__.'/vendor/autoload.php';

use Symfony\Component\VarDumper\VarDumper;
use Symfony\Component\VarDumper\Dumper\HtmlDumper;
use Symfony\Component\VarDumper\Cloner\VarCloner;

$varDumper = new VarDumper();
$varDumper::setHandler();

$cloner = new VarCloner();

$htmlDumper = new HtmlDumper();
$htmlDumper->setTheme('light');

VarDumper::setHandler(function ($var) use ($cloner, $htmlDumper) {
$htmlDumper->dump($cloner->cloneVar($var));
});

$data = [
'Now',
'this',
'should be',
'lighter!',
];

dump($data);

.. image:: /_images/components/var_dumper/10-light-theme.png

.. versionadded:: 4.2
The :method:`Symfony\\Component\\VarDumper\\Dumper\\HtmlDumper::setTheme` method was introduced in Symfony 4.2.

.. note::
The :method:`Symfony\\Component\\VarDumper\\Dumper\\HtmlDumper::setTheme` method only works with the :class:`Symfony\\Component\\VarDumper\\Dumper\\HtmlDumper` class.


Learn More
----------

Expand Down