kirik/web-profiler-ui
Composer 安装命令:
composer require kirik/web-profiler-ui
包简介
Multiplatform WEB profiler
README 文档
README
Created to simplify the process of searching for bottlenecks in web projects. Click here to see it in action.
Features
- Backend-independent design: can be used with any backend (PHP, Golang, Node.js, Java, ...)
- PHP
supported(please refer to the library) - Golang
in development - For others, please don't hesitate to PR an adapter for your programming language
- PHP
- Docked mode
- Floating window mode
- Waterfall span view
- AJAX requests support
- Small footprint
- No dependencies: written with vanilla JS, CSS, and HTML
- Stateful with localStorage (remembers docking/floating mode, folding, and size)
- Go to row from Summary view (just click on span)
Floating window mode
Docked mode
Build&Run
You don't need to run anything just to play with the profiler. Please see the playground.
If you'd like to run the project locally:
- Clone this project
git clone git@github.com:kirik/web-profiler-ui.git && cd web-profiler-ui
- Run any HTTP server to open
index.html:
Python
python3 -m http.server
PHP
php -S localhost:8000
IntelliJ IDEs
You can run the project with your IntelliJ IDE using the embedded web server. Just open index.html and click on
your favorite browser icon in the browser toolbar:

Internals
Profiler is embedded using an iframe just to avoid CSS collisions with the parent page.
- script.js contains all JS used to render profiling data
- style.css contains the main CSS for the profiler
- template.html is the main template file
Backends should send an appropriate response to be parsed by the profiler and draw spans:
{
// (string) URI
"request_uri": "/uri/requested/",
// (int) overall memory used by the request in bytes
"peak_memory": 0,
// (array) collectors objects, see `Collector object`
"collectors_data": [],
// (float) Unix timestamp with microseconds
"start_time": 1708231434.391469,
// (float) overall time used to respond in seconds (with microseconds)
"duration": 0.39930295944213867,
// Not Implemented Yet
"request_headers": [],
// Not Implemented Yet
"response_headers": []
}
Collector object
{
"props": {
// (string, required) title to show in the profiler's tab
"title": "Log",
// (string, required) template for collector's data to display; available templates:
// - `table`: data will be displayed as a table
// - `html`: data will be shown as HTML
"template": "table",
// (string, optional) color associated with this collector
// - can be either hex `#af0000`, `rgb(255,0,0)` or color name `gold`
// - if no color is specified, a predefined color will be associated (by CRC32 from `title` and a 216-color palette)
"cssColor": "#663333",
// (float, required) summary time for this collector
"duration": 0,
// (object, required) list of metrics, which this collector is collecting
"metrics": {
// (string, required) metric key (unique in metrics context)
"key": {
// (string, required) metric title, which will be displayed
"title": "Title",
// (string, required) metric data type - different types have their own format logic:
// - `seconds` - will be formatted as Xs/Xms/Xμs
// - `bytes` - will be formatted as XB/XKiB/XMiB/...
// - `unixtime` - will be formatted as time (for example: 23:43:54)
// - `integer` - will be formatted as a number
// - `json` -
// - `text` - long texts (such as SQL queries)
// For `table` template, the following features are available:
// text will be truncated with ellipses (using CSS);
// duplicated values will be highlighted;
// copy the full content on double click;
// - `string` (default) - just a string value, will not be truncated as opposed to `text` type
"type": "type"
},
// `__start_time` and `__duration` are standard metrics which will be used to generate the Summary tab
// with spans waterfall. You can skip these metrics to not display the collector in the Summary tab
"__start_time": {
"title": "Start time",
"type": "seconds"
},
"__duration": {
"title": "Duration",
"type": "seconds"
}
}
},
"data": [
{
"message": "\"test\"",
"file_line": "\/var\/www\/html\/App\/Dbg\/Controller\/Index.php:362",
"time": 1708231434
}
]
}
To render AJAX responses, they should provide a full response with the __profiler property along with business data:
{
...,
"__profiler": {
/*full profiler response*/
}
}
I'm avoiding using HTTP headers to send profiler data with AJAX as it requires special settings for HTTP servers. I also don't like to save responses to files to use them later, as it requires a writable filesystem and other file-related logic (be KISS).
Adapters
An adapter is a small piece of language-related code (aka interface) to connect the UI to the web project. Supported adapters:
- PHP (library)
- Golang (WIP)
Developing
Makefile is used just to minify CSS and JS after editing.
PHP adapter
Please initialize Composer with the command
composer dumpautoload
and then open index.php.
Roadmap
- create playground
- add php library
- add golang adapter and library
- add dark mode
kirik/web-profiler-ui 适用场景与选型建议
kirik/web-profiler-ui 是一款 基于 JavaScript 开发的 Composer 扩展包,目前已累计 16 次下载、GitHub Stars 达 1, 最近一次更新时间为 2024 年 02 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 kirik/web-profiler-ui 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 kirik/web-profiler-ui 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 16
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 5
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-02-18

