All Projects → yiisoft → var-dumper

yiisoft / var-dumper

Licence: BSD-3-Clause License
Helper for dumping variable for debug purposes

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to var-dumper

dd
This package will add the dd and dump helpers to your Phalcon application.
Stars: ✭ 17 (+30.77%)
Mutual labels:  debug, dump, vardumper
xr
Lightweight debug server utility for PHP.
Stars: ✭ 116 (+792.31%)
Mutual labels:  debug, dump
yii-debug
Yii debug panel extension
Stars: ✭ 23 (+76.92%)
Mutual labels:  debug, yii3
Ray
Debug with Ray to fix problems faster
Stars: ✭ 263 (+1923.08%)
Mutual labels:  debug, dump
godump
Dumps information about a variable Like var_dump() in php.
Stars: ✭ 54 (+315.38%)
Mutual labels:  debug, dump
var-trumper
Make VarDumper great again
Stars: ✭ 16 (+23.08%)
Mutual labels:  dump, vardumper
Laravel Artisan Dd
Quickly run some code via Artisan
Stars: ✭ 136 (+946.15%)
Mutual labels:  debug, dump
app
Buggregator is a beautiful, lightweight debug server build on Laravel that helps you catch your smpt, sentry, var-dump, monolog, ray outputs. It runs without installation on multiple platforms.
Stars: ✭ 259 (+1892.31%)
Mutual labels:  dump, vardumper
SmartDump
SmartDump - an exception and memory dump capture utility
Stars: ✭ 17 (+30.77%)
Mutual labels:  debug, dump
Unity-File-Debug
Enhanced debug logging for Unity, with JSON/CSV export and HTML viewer.
Stars: ✭ 50 (+284.62%)
Mutual labels:  debug
python-yamlable
A thin wrapper of PyYaml to convert Python objects to YAML and back
Stars: ✭ 28 (+115.38%)
Mutual labels:  dump
pydbg
Python implementation of the Rust `dbg` macro
Stars: ✭ 85 (+553.85%)
Mutual labels:  debug
AllYourMemoriesAreBelong2iOS
💪 Simulate iOS on-device memory warnings like a hero.
Stars: ✭ 17 (+30.77%)
Mutual labels:  debug
XDebugger
A very lightweight library (4Kb) to create a development or production debugger with custom errors readable for humans. Includes errors in table format, logger and search methods with dynamic filters.
Stars: ✭ 18 (+38.46%)
Mutual labels:  debug
yii-masked-input
Yii Framework Masked input widget Extension
Stars: ✭ 38 (+192.31%)
Mutual labels:  yii3
kube-debug
一鍵調試kubernetes和docker容器的Web視覺化工具箱。A toolbox for debugging docker container and kubernetes with web UI.
Stars: ✭ 46 (+253.85%)
Mutual labels:  debug
hugo-bare-min-theme
A bare minimum theme for Hugo (https://gohugo.io) to help develop and debug Hugo sites -- https://hugo-bare-min.netlify.com/,
Stars: ✭ 71 (+446.15%)
Mutual labels:  debug
MCUCapture
Utility for plotting array data from MCU RAM
Stars: ✭ 22 (+69.23%)
Mutual labels:  debug
ignition-tinker-tab
An Ignition tab to tinker with your Laravel app
Stars: ✭ 30 (+130.77%)
Mutual labels:  debug
state inspector
State change & method call logger. A debugging tool for instance variables and method calls.
Stars: ✭ 24 (+84.62%)
Mutual labels:  debug

Yii VarDumper


Latest Stable Version Total Downloads Build Status Scrutinizer Code Quality Code Coverage Mutation testing badge static analysis type-coverage

VarDumper enhances functionality of var_dump() and var_export(). It is dealing with recursive references, may highlight syntax and export closures.

Requirements

  • PHP 7.4 or higher.

Installation

The package could be installed with composer:

composer require yiisoft/var-dumper --prefer-dist

General usage

Quick debugging

In case you want to echo a string representing variable contents use the following code:

\Yiisoft\VarDumper\VarDumper::dump($variable);

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:

// Prints variables:
d($variable, /* Further variables to dump. */);

// Prints variables and terminate the current script:
dd($variable, /* Further variables to dump. */);

Formatting debug string

To get a string representing variable contents, same as above but without echo:

$string = \Yiisoft\VarDumper\VarDumper::create($variable)->asString(10, true);

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:

$string = \Yiisoft\VarDumper\VarDumper::create($variable)->export();

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.

Limitations

Current limitations are:

  • Variables or properties that are anonymous classes or contain anonymous classes are not supported.

Unit testing

The package is tested with PHPUnit. To run tests:

./vendor/bin/phpunit

Mutation testing

The package tests are checked with Infection mutation framework with Infection Static Analysis Plugin. To run it:

./vendor/bin/roave-infection-static-analysis-plugin

Static analysis

The code is statically analyzed with Psalm. To run static analysis:

./vendor/bin/psalm

Support the project

Open Collective

Follow updates

Official website Twitter Telegram Facebook Slack

License

The Yii Caching Library is free software. It is released under the terms of the BSD License. Please see LICENSE for more information.

Maintained by Yii Software.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].