perchten/neat_html
Composer 安装命令:
composer require perchten/neat_html
包简介
Pretty-print PHP objects and arrays in html, json etc.
关键字:
README 文档
README
Prettier html printing of php objects and arrays
Installation
Via Composer
Neat_html is available on Packagist (perchten/neat_html) and as such is installable via Composer.
Add the following to your composer.json
{
"require": {s
"perchten/neat_html": "1.*"
}
}
Direct include
Clone or download from GitHub and include directly in your code:
require_once "path/to/neat_html.php"
Usage
Simple neat_html
neat_html($somevar)
Will print $somevar into html as a <pre>-wrapped block formatted like JSON.
Return, Don't Print
$output = neat_html($somevar,true)
As with neat_html($somevar) except that the output is returned, captured in the $output variable and not printed.
Die Immediately After Debug Print
neat_html($somevar,"die")
Outputs the formatted $somevar and then dies.
Output as Html Comment
neat_html($somevar,"comment")
Outputs the formatted code in comment form. comments start <!--neat_html for easy searching.
Do not wrap in <pre> tags
neat_html($somevar,"nopre")
Outputs the formatted code without wrapping it in <pre> tags. Useful for console printing.
Print Included Files
neat_html($somefileref,'include)
Takes $somefileref as a file reference and includes that file's contents. Obviously, if the included file uses undefined variables then it will fail.
Also, the file reference must be absolute. For convenience a truepath function is included to get the real path. (PHP's realpath() function is a bit buggy, so best not use that. see http://stackoverflow.com/questions/4049856/replace-phps-realpath). e.g.
neat_html(truepath($somefileref),'include')
Output in JSON (Handy For Ajax)
neat_html($somevar,'json')
Returns the object in json notation. Handy when debugging over ajax that expects a json response.
Output in PHP (Handy For Purists ;))
neat_html($somevar,'php')
Returns the object in php notation. This then uses the var_export function instead of print_r. So the returned values here can even be interpreted directly as php variables.
Multiple Arguments
You can also collect multiple arguments together in a second argument array as follows:
neat_html($somevar,array("include","comment","return");
Or as a comma or space separated list:
neat_html($somevar,"include, comment, return");
And, as of v1.2 you can even use dynamic arguments:
neat_html($somevar,"include","comment","return");
var_dump
neat_html($somevar,'dump');
This will run all data manipulation on $somevar (including if it is a file include), and then var_dump the result in addition to outputting in any other specified formatting.
Defaults
You can set defaults at a global level if you find yourself repeating the same optional arguments all the time.
Neat_Html::setDefault($option);
Neat_Html::getDefaults();
Neat_Html::setDefaults($optionsArray);
Neat_Html::removeDefault($option);
Enabling/Disabling
neat_html statements will run by default, but you can control this by switching the functionality on and off globally, and querying the current state.
Neat_Html::setOn() // switches this module on globally
Neat_Html::setOff() // switches this module off globally
Neat_Html::isOn() // return true if module is on, otherwise false
License
Neat_html is licensed under the MIT License - see the LICENSE file for details
perchten/neat_html 适用场景与选型建议
perchten/neat_html 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.03k 次下载、GitHub Stars 达 4, 最近一次更新时间为 2014 年 05 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「json」 「debug」 「console」 「html」 「comments」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 perchten/neat_html 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 perchten/neat_html 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 perchten/neat_html 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Debug your SimpleBus EventBus and CommandBus
nice output for debug functions for PHP 5.3
Kinikit - PHP Application development framework MVC component
ext-json wrapper with sane defaults
A package to cast json fields, each sub-keys is castable
Analysis module for finding problematical shop data.
统计信息
- 总下载量: 2.03k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 18
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-05-13