swow-cloud/xr
Composer 安装命令:
composer require swow-cloud/xr
包简介
Lightweight debug server utility.
README 文档
README
🔔 Subscribe to the newsletter to don't miss any update regarding Chevere.
Crocanty.mp4
XR is a dump debug server utility for PHP. No extras required, debug your PHP code anywhere.
Features
- 💎 Colorful, typed, easy-on-the eye dump variable highlight
- ✨ Dump n arguments
- 🐘 One-click PHP server run (no extras required)
- 👻 Filter messages by Topics and Emotes
- ✍️ Re-name "XR Session" to anything you want
- 🏁 Resume, Pause, Stop and Clear debug window controls
- 🥷 Keyboard shortcuts for ninjas (Resume R, Pause P, Stop S and Clear C)
- 😊 Export message to clipboard (plain text) or as inline-download PNG image
- 📟 Generates dump backtrace
- ⏸ Pause and resume your code execution (*not implemented)
- 🌚 Dark / 🌝 Light mode follows your system preferences
- 👽 Ephemeral, it doesn't store any persistent data
- 🍒 HTML based (save page, search, shortcuts, etc.)
- 🔥 Uses FiraCode font for displaying beautiful looking dumps ™
- 😅 Handle exceptions (hook or replace your existing handler)
Contributing
Feel free to contribute on issues and discussions with your thoughts in how to improve XR.
Getting started
- Add
chevere/xras a dev dependency in your project:
composer require --dev chevere/xr
🚧 Min stability dev
You will require to add this to your composer.json file.
"minimum-stability": "dev", "prefer-stable": true
Start the server
php vendor/chevere/xr/server.php -p 27420
The server will be available at http://localhost:27420
Demo
Open the debugger and then run:
php vendor/chevere/xr/demo.php
XR Helpers
Dump variables
Use xr($var1, $var2,...) to dump any variable from your code.
xr($var, 'Hola, mundo!');
Topic
Add a topic passing t:.
xr( $var, 'Hola, mundo!', t: 'Epic win' );
Emote
Add an emote passing e:.
xr( $var, 'Hola, mundo!', t: 'Epic win', e: '😎' );
Flags
Pass bitwise flags to trigger special behavior.
f: XR_BACKTRACEto dump debug backtrace.
xr( $var, 'Hola, mundo!', t: 'Epic win', e: '😎', f: XR_BACKTRACE );
f: XR_PAUSEto pause code execution (*not implemented).
xr( $var, 'Hola, mundo!', t: 'Epic win', e: '😎', f: XR_PAUSE );
Send raw message
Use xrr to send a raw message to the server.
💡 xrr also supports topic t, emote e and flags f arguments.
xrr( '<h1>Hola, mundo!</h1>', t: 'Greet' );
Exception handling
Use registerThrowableHandler to enable XR to handle throwables.
use Chevere\Xr\registerThrowableHandler; // True append XR's to your existing handler // False use only XR's handler registerThrowableHandler(true);
Alternatively, you can use throwableHandler in any existing exception handler logic:
use Chevere\Xr\throwableHandler; set_exception_handler( function(Throwable $throwable) { // ... try { throwableHandler($throwable); } catch(Throwable) { // Don't panic } } );
Error handling
You will require to handle errors as exceptions and from there use Exception handling.
use use Chevere\ThrowableHandler\ThrowableHandler; set_error_handler( ThrowableHandler::ERRORS_AS_EXCEPTIONS ); register_shutdown_function( ThrowableHandler::FATAL_ERROR_HANDLER );
Configuration
Optionally configure XR by creating a file named xr.php in your project directory with the following options:
enableboolControls sending messages to the server. Set true to enable, false to disable.
hoststringThe hostname/IP address where XR server is running.
portintPort to connect to thehost.
The following example is a xr.php file with default settings.
<?php return [ 'enable' => true, 'host' => 'localhost', 'port' => 27420, ];
For software providers
If you want to handle XR settings somewhere within your existing application logic (not depend on the xr.php file) you can do:
use Chevere\Xr\XrInstance; // (...) your logic sets $enable, $host and $port new XrInstance( new Xr(enable: $enable, host: $host: port: $port) );
Docker
See DOCKER.
Message reference
The XR dump server can receive messages from anywhere:
POST http://localhost:27420/message
body=Hola, mundo
file_path=/var/www/file.php
file_line=123
...
body- The message raw body (HTML).file_path- The file path.file_line- The file line.emote- emote (emojis/symbols)topic- Topic as message context.
License
Copyright 2022 Rodolfo Berrios A.
XR is licensed under the Apache License, Version 2.0. See LICENSE for the full license text.
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
swow-cloud/xr 适用场景与选型建议
swow-cloud/xr 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 7 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 02 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 swow-cloud/xr 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 swow-cloud/xr 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 7
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2022-02-10



