edemeijer/serialize-debugger
Composer 安装命令:
composer require edemeijer/serialize-debugger
包简介
A tool for debugging failing or dangerous PHP serialize() calls
关键字:
README 文档
README
A tool for debugging failing or dangerous PHP serialize() calls.
Motivation
Debugging issues with PHP's serialize() method can be a tedious task, because it doesn't give much information when it
encounters errors. This is best demonstrated with an example:
<?php $nestedStruct = [ 'foo' => (object) [ 'validProp' => 42, 'invalidProp' => function () {}, ], 'bar' => [ 'someProp' => 'Hello', ], ]; $serialized = serialize($nestedStruct);
The above code will result in a fatal error:
PHP Fatal error: Uncaught exception 'Exception' with message 'Serialization of 'Closure' is not allowed' in /path/to/script.php:13
Stack trace:
#0 /path/to/script.php(13): serialize(Array)
#1 {main}
thrown in /path/to/script.php on line 13
Not very helpful, is it? Where is this closure located exactly? Imagine this happening with big, nested structures, and you're in for a lot of in-the-dark debugging fun.
This is where serialize-debugger can lend a helping hand. Look at the following PHP snippet and its output:
Debugger::debugPlaintext($nestedStruct);
Closure - ERROR
{root}[foo]->invalidProp
Much better, now we know exactly where the offending closure is located in the problematic data structure.
Requirements
serialize-debugger is only supported on PHP 5.4.0 and up.
Installation
Using composer, add to your composer.json:
"edemeijer/serialize-debugger": ">=0.1.1"
Then run composer.phar update
API
Basic usage:
// There are two static convenience methods in the main debugger class: // Outputting errors and warnings in plain text format Debugger::debugPlaintext($data); // Outputting errors and warnings in HTML format Debugger::debugHTML($data); // Both methods provide an optional second boolean parameter for verbose output // This will output not only errors and warnings, but the paths to every element // in the data set Debugger::debugPlainText($data, true);
Without using the static convenience methods:
$debugger = new Debugger(); $formatter = new PlainTextFormatter(); $result = $debugger->debug($data, $verbose); echo $formatter->format($result);
License
MIT - See LICENSE file.
edemeijer/serialize-debugger 适用场景与选型建议
edemeijer/serialize-debugger 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 110.8k 次下载、GitHub Stars 达 10, 最近一次更新时间为 2014 年 08 月 27 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「serialize」 「debugging」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 edemeijer/serialize-debugger 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 edemeijer/serialize-debugger 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 edemeijer/serialize-debugger 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
LazyPDO is a set of wrappers over PHP's standard PDO and PDOStatement classes. It enables lazy loading, serialization and decoration.
Transform data structures
Lightweight PHP library that allows exchanging binary data with Qt programs (QDataStream)
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.
Runn Me! Serialization Library
统计信息
- 总下载量: 110.8k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 10
- 点击次数: 11
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-08-27