Download the PHP package yiisoft/var-dumper without Composer
On this page you can find all versions of the php package yiisoft/var-dumper. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download yiisoft/var-dumper
More information about yiisoft/var-dumper
Files in yiisoft/var-dumper
Package var-dumper
Short Description Enhances functionality of var_dump() and var_export(). It is dealing with recursive references, may highlight syntax and export closures.
License BSD-3-Clause
Homepage https://www.yiiframework.com/
Informations about the package var-dumper
Yii VarDumper
VarDumper
enhances functionality of var_dump()
and var_export()
. It is dealing with recursive references,
may highlight syntax and export closures.
Requirements
- PHP 8.0 or higher.
Installation
The package could be installed with Composer:
General usage
Quick debugging
In case you want to echo a string representing variable contents use the following code:
That is useful for quick debugging. By default, it goes deep 10
levels into variable and highlights syntax. You may
adjust these settings via second and third argument of the method respectively.
For convenience, you can use the functions:
Formatting debug string
To get a string representing variable contents, same as above but without echo
:
10
is maximum recursion depth and true
is telling dumper to
highlight syntax.
Exporting as PHP code
In order to get a valid PHP expression string that can be evaluated by PHP parser, and the evaluation result will give back the variable value, use the following code:
It is similar to var_export()
but uses short array syntax, handles closures, and serializes objects.
In the above export()
will give you nicely formatted code. You can remove formatting by passing false
as the first
$format
argument.
$useVariables
argument allows specifying array of variables that will be in use
statement for closures.
That is especially useful if an object contains callbacks that should get info from upper scope.
$serializeObjects
argument when given false
allows to force turn off using of serialization for objects so instead
closures and reflection API are used the same was as for exporting closures. De-serialization performance is better.
Closures are way more readable.
Exporting as JSON string
It is similar to json_encode()
but uses short array syntax, handles closures, and serializes objects.
In the above asJson()
will give you nicely formatted code. You can remove formatting by passing false
as the first
$format
argument.
$depth
argument allows you to set maximum recursion depth.
Output destination
Choose one of existing classes or create a new one to control the destination where "dumps" will be sent to:
- EchoHandler
- Uses
echo
to write to stdout stream. - Used by default.
- Uses
- StreamHandler
- Uses
ext-sockets
to sent dumps encoded withjson_encode
to a UDP socket.
- Uses
- CompositeHandler
- Helpful class to sent dumps to multiple handlers in a row, for example
EchoHandler
andStreamHandler
.
- Helpful class to sent dumps to multiple handlers in a row, for example
Output handlers are set via VarDumper::setDefaultHandler()
method.
Limitations
Current limitations are:
- Variables or properties that are anonymous classes or contain anonymous classes are not supported.
Documentation
- Internals
If you need help or have a question, the Yii Forum is a good place for that. You may also check out other Yii Community Resources.
License
The Yii VarDumper is free software. It is released under the terms of the BSD License.
Please see LICENSE
for more information.
Maintained by Yii Software.
Support the project
Follow updates
All versions of var-dumper with dependencies
ext-json Version *
ext-mbstring Version *
ext-tokenizer Version *
yiisoft/arrays Version ^1.0|^2.0|^3.0