aronduby/dump
Composer 安装命令:
composer require aronduby/dump
包简介
D::ump - a PHP 5.4 print_r/var_dump replacement base on Krumo
README 文档
README
A print_r/var_dump replacement for PHP >= 5.4.0 based on Krumo and the oodle/krumo fork.
Differences from Krumo
- modified HTML, CSS, and JS has been completely reworked, makes multiple arguments passed look like they're together
- added Passing in bitmask to be able to do Titles, Output Buffering, and Stopping Executing after output
- added Object Reflection to not only show the properties (which are now sorted as arrays) but also:
- Parent Class Name
- Interface Names
- Trait Names
- Constants
- Methods (with the argument list and defaults*)
- added Callables are now first class citizens instead of strings, complete with argument list and defaults* from reflection
- removed All the different skins, if you really want it to look different there's a
css_fileconfig option, but who cares, its development - removed All the helper functions, because why not just type
D::ump($_ENV), not like your going to remember them all anyway - removed .ini settings file is gone, use
D::config()if you want to set global changes - probably some other things...
Note: reflection can't get the default values for arguments of built-in methods/functions, it will display the argument name with a note in these circumstances
Install
Using Composer
{
"require": {
"aronduby/dump" : "*"
}
}
then run composer install or composer update
Usage
Basic Usage
D::ump($arg1);
You can also pass multiple arguments:
D::ump($arg1, $arg2, $arg3);
Dump Settings
If you pass an instance of D\DumpSettings as the last argument to D::ump you can set a title, output buffer the return, kill the process after returning, and expand all the collapsibles by default.
$ds = new \D\DumpSettings(D::KILL | D::EXPAND, 'This is a Title'); D::ump($arg1, $arg2, $ds);
Short Cut:
The D object has a shortcut to quickly create and return an instance of D\DumpSettings, so the same example could be rewritten as
D::ump($arg1, $arg2, D::S(D::KILL | D::EXPAND, 'This is a Title'));
Flags
The following flags are available as constants of the D class:
- D::KILL -- will call die() after output
- D::OB -- will use the output buffer and return the output instead of printing it
- D::EXPAND -- starts with the output fully expanded
- D::IGNORE_CLI -- by default, if the script detects you are running command line it just uses
print_r, use this to include the full output, useful if you are doing html logging
Note: Passing a bitmask containing both D::KILL and D::OB will result in an InvalidArgumentException being thrown since you can't do both
Note: D\DumpSettings also has a backtrace property which is used by D::ump()
Config
You can globally modify the following properties by passing an associative array into D::config($arr) with the following values
| Key | Type | Default | Description |
|---|---|---|---|
| enabled | Boolean | true | globally enabled/disable output, can also call D::disable & D::enable |
| css_file | String | null | path to a custom CSS file, file will be read in using file_get_contents, should be absolute path |
| display.separator | String | => | string to use as a separator between the key/values (the default is wrapped in spaces) |
| display.truncate_length | Integer | 80 | If a string is longer than X characters it will be truncated with the non-truncated version displaying as a collapsible |
| display.cascade | Array | null | Array of integers to determine when a level should collapse. If the specified level has greater than X amount of element it shows collapsed. display.cascade=>[5,10] will expand the first level if there are 5 or less items and the second level with 10 or less. Set to null to have everything collapse |
| display.show_version | Boolean | true | Include version # and link in the footer of the output |
| display.show_call_info | Boolean | true | Include the file/line # D was called from |
| display.replace_returns | Boolean | false | Should we replace returns \n with br's in the output |
| sorting.arrays | Boolean | true | Reorder associative arrays (and object properties and methods) based on their keys |
Example
D::config([ 'css_file' => "absolute/path/to/your/custom/css/file.css", 'display.cascade' => [5, 10], 'sorting.arrays' => false ]); // ... some other stuff in your code D::ump($arg1);
aronduby/dump 适用场景与选型建议
aronduby/dump 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.26M 次下载、GitHub Stars 达 4, 最近一次更新时间为 2014 年 03 月 31 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「debug」 「dump」 「debugging」 「pretty」 「print」 「print_r」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 aronduby/dump 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 aronduby/dump 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 aronduby/dump 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
This package will add the `dd` and `dump` helpers to your Phalcon application.
Debug your SimpleBus EventBus and CommandBus
Simple Twig extension improving templates debugging
nice output for debug functions for PHP 5.3
A PHP package that takes a snapshot of your application and allows you to retrieve it later to help with debugging.
Laravel Database Query Logger and debug helper.
统计信息
- 总下载量: 1.26M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 39
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2014-03-31