decodelabs/glitch
Composer 安装命令:
composer require decodelabs/glitch
包简介
Better tools for when things go wrong
关键字:
README 文档
README
Better tools for when things go wrong
Glitch is a standalone PHP package designed to dramatically improve error handling and inspection when developing your applications.
The project aims to provide deep data inspection tools and an Exception handling interface.
Installation
This package requires PHP 8.4 or higher.
Install via Composer:
composer require decodelabs/glitch
Usage
use DecodeLabs\Glitch; use DecodeLabs\Monarch; $glitch = Monarch::getService(Glitch::class); $glitch->dump('hello');
Setup
Otherwise, Glitch works out of the box without any special setup. There are however some optional steps you can take to customise operation.
Register as the default error handler:
$glitch->registerAsErrorHandler();
Pass the microtime() of initial app launch for timing purposes:
$glitch->setStartTime(microtime(true));
Dumps
Dump anything and everything easily, using simple global functions. The functions mirror those used in Symfony/VarDumper, maintaining compatibility by using Symfony's VarDumper interface if it is already loaded.
class MyThing {} $myObject = new MyThing(); // This will dump the object and carry on dump($myObject); // This will dump the object and exit dd($myObject);
Renderers
The resulting dump UI (when using the HTML renderer, the default option) is injected into an iframe at runtime so can be rendered into any HTML page without breaking anything. If the page is otherwise empty, the iframe will expand to fill the viewport if possible.
The dump output is rendered by an instance of DecodeLabs\Glitch\Renderer which can be overridden on the default Service at startup. The Html renderer is loaded under http sapi, the Cli renderer is used when under the CLI sapi.
Custom renderers may convert Entities to other output formats depending on where they should be sent, such as Xml or Json for example. The Renderer system uses Nuance to inspect and render the data, please see that project for more information on how to create custom renderers.
Custom colours
The HTML renderer uses css variables to style individual element colours and can be overridden with custom values. Create a custom css file with variable overrides:
:root { --string: purple; --binary: green; }
See colours.scss for all of the current colour override options.
Then load the file into the HTML renderer:
$glitch->getRenderer()->setCustomCssFile('path/to/my/file.css');
Transports
Once rendered, the dump information is delivered via an instance of DecodeLabs\Glitch\Transport, also overridable on the default Service. It is the responsibility of the Transport to deliver the rendered dump.
By default, the render is just echoed out to STDOUT, however custom transports may send information to other interfaces, browser extensions, logging systems, etc.
Custom dumps
You can customise how your own class instances are dumped by implementing DecodeLabs\Nuance\Dumpable interface.
Please see the Nuance documentation for more information on how to do this.
Licensing
Glitch is licensed under the MIT License. See LICENSE for the full license text.
decodelabs/glitch 适用场景与选型建议
decodelabs/glitch 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 22.87k 次下载、GitHub Stars 达 7, 最近一次更新时间为 2019 年 09 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「debug」 「dump」 「exception」 「dumper」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 decodelabs/glitch 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 decodelabs/glitch 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 decodelabs/glitch 相关的其它包
同方向 / 同关键字的高下载量 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
Analysis module for finding problematical shop data.
Twig extensions for Tracy Debugger
统计信息
- 总下载量: 22.87k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 7
- 点击次数: 13
- 依赖项目数: 3
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-09-09
