承接 yiisoft/var-dumper 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

yiisoft/var-dumper

Composer 安装命令:

composer require yiisoft/var-dumper

包简介

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

README 文档

README

Yii

Yii VarDumper


Latest Stable Version Total Downloads Build status 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 8.0 - 8.5.

Installation

The package could be installed with Composer:

composer require yiisoft/var-dumper

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. */);
// The same as above
dump($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.

Exporting as JSON string

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

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.
  • StreamHandler
    • Uses ext-sockets to sent dumps encoded with json_encode to a UDP socket.
  • CompositeHandler
    • Helpful class to sent dumps to multiple handlers in a row, for example EchoHandler and StreamHandler.

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

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

Open Collective

Follow updates

Official website Twitter Telegram Facebook Slack

yiisoft/var-dumper 适用场景与选型建议

yiisoft/var-dumper 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.32M 次下载、GitHub Stars 达 21, 最近一次更新时间为 2019 年 05 月 06 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「framework」 「helper」 「yii」 「var-dumper」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 yiisoft/var-dumper 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 yiisoft/var-dumper 我们能提供哪些服务?
定制开发 / 二次开发

基于 yiisoft/var-dumper 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 1.32M
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 21
  • 点击次数: 35
  • 依赖项目数: 34
  • 推荐数: 0

GitHub 信息

  • Stars: 21
  • Watchers: 14
  • Forks: 13
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2019-05-06