kktsvetkov/krumo
Composer 安装命令:
composer require kktsvetkov/krumo
包简介
Krumo is a debugging tool, which displays structured information about any PHP variable. It is a nice replacement for print_r() or var_dump() which are used by a lot of PHP developers.
README 文档
README
Krumo: PHP structured information display solution
Krumo is a debugging tool, which displays structured information about any PHP variable.
It is a nice replacement for print_r() or var_dump() which are used by a lot of PHP developers.
Overview
To put it simply, Krumo is a replacement for print_r() and var_dump(). By definition Krumo
is a debugging tool, which displays structured information about any PHP variable.
A lot of developers use print_r() and var_dump() in the means of debugging
tools. Although they were intended to present human readable information about a
variable, we can all agree that in general they are not. Krumo is an
alternative: it does the same job, but it presents the information beautified
using CSS/JS/HTML.
Installation
This library can be installed in autoloadable way using Composer as kktsvetkov/krumo.
php composer.phar require kktsvetkov/krumo
In the rare occasion that you are dealing with some legacy code that
has not yet embraced Composer, you can also download this package,
and include class.krumo.php in your project, or make it accessible
somewhere in your INCLUDE_PATH:
include 'class.krumo.php';
More or less, that's it.
Examples
Here's a basic example, which will return a report on the array variable passed as argument to it:
krumo(array('a1'=> 'A1', 3, 'red'));
You can dump simultaneously more then one variable - here's another example:
krumo($_SERVER, $_REQUEST);
You probably saw from the examples above that some of the nodes are expandable, so if you want to inspect the nested information, click on them and they will expand; if you do not need that information shown simply click again on it to collapse it. Here's an example to test this:
$x1->x2->x3->x4->x5->x6->x7->x8->x9 = 'X10'; krumo($x1);
The krumo() is the only standalone function from the package, and this is
because basic dumps about variables (like print_r() or var_dump()) are the most
common tasks such functionality is used for. The rest of the functionality can
be called using static calls to the Krumo class. Here are several more examples:
// print a debug backgrace krumo::backtrace(); // print all the included(or required) files krumo::includes(); // print all the included functions krumo::functions(); // print all the declared classes krumo::classes(); // print all the defined constants krumo::defines();
... and so on, etc.
Please note that the first time you call Krumo the dump it produces also
prints the CSS and the JS code used to expand/collapse the dump nodes.
krumo::fetch()
If you want to get the output returned instead of printed, you can use
the krumo::fetch() method for that:
$a = krumo::fetch($app, $env);
krumo::queue()
It's been a valid complain that sometimes Krumo output is called in the middle
of some opened HTML tag, and that breaks the output of both that tag and Krumo
itself. You can use krumo::queue() instead of krumo::dump() to solve that
problem, since krumo::queue() will print its output at the end of the script:
krumo::queue($request);
Skins
There are several skins pre-installed with this package, but if you wish you can create skins of your own. The skins are simply CSS files that are prepended to the result that Krumo prints.
To the Krumo skin, you have to set it at krumo::$skin:
krumo::$skin = 'blue';
Here is a list of the pre-installed skins in Krumo
skins/kaloyan.info
This is the new default theme, kaloyan.info. It is not as color heavy as the other skins
// set up using the "kaloyan.info" skin krumo::$skin = 'kaloyan.info';
skins/default
As the name suggests, this is the old "default" theme.
// set up using the "default" skin krumo::$skin = 'default';
skins/blue
This is a blue version of the old default theme
// set up using the "blue" skin krumo::$skin = 'blue';
skins/orange
This is an orange version of the old default theme
// set up using the "orange" skin krumo::$skin = 'orange';
skins/green
This is a green version of the old default theme
// set up using the "green" skin krumo::$skin = 'green';
License
This project is released under GNU Lesser General Public License v2.1 opensource.org/licenses/LGPL-2.1
History
The project was first hosted and maintained at sourceforge.net/projects/krumo/.
kktsvetkov/krumo 适用场景与选型建议
kktsvetkov/krumo 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 62.18k 次下载、GitHub Stars 达 82, 最近一次更新时间为 2017 年 11 月 20 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「debug」 「debugging」 「development」 「print_r」 「var_dump」 「krumo」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 kktsvetkov/krumo 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 kktsvetkov/krumo 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 kktsvetkov/krumo 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Debug your SimpleBus EventBus and CommandBus
nice output for debug functions for PHP 5.3
Debugging a problem and need to login as one of your customers? This allows you to authenticate as any of your customers.
A PHP package that takes a snapshot of your application and allows you to retrieve it later to help with debugging.
Library with classes to help you do batch.
Laravel Database Query Logger and debug helper.
统计信息
- 总下载量: 62.18k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 83
- 点击次数: 29
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: LGPL-2.1
- 更新时间: 2017-11-20