dbugapp/dbug-php
Composer 安装命令:
composer require dbugapp/dbug-php
包简介
Send debug payloads from PHP to the dbug desktop app
README 文档
README
Send debug payloads from PHP to the dbug desktop app. The Dbug PHP SDK allows you to easily send structured debug information from your PHP application to a local server running the dbug desktop app for interactive debugging.
Features
- Serialize complex PHP data structures to JSON with circular reference handling.
- Send payloads to a local
dbugdesktop app instance via HTTP. - Easily configure the endpoint to customize the server URL.
- Designed for local development and debugging.
Installation
You can install the dbug-php SDK via Composer.
composer require dbugapp/dbug-php --dev
Usage
Basic Usage
Send debug payloads by calling the send() method:
use DbugApp\Dbug; Dbug::send([ 'event' => 'user.registered', 'user' => [ 'id' => 123, 'email' => 'user@example.com', ], ]);
This will serialize the payload and send it to the default dbug server at http://127.0.0.1:53821.
Custom Endpoint
If you need to change the endpoint (e.g., for testing or different environments), you can use the setEndpoint() method to specify a custom URL:
Dbug::setEndpoint("http://127.0.0.1:54000"); // Set custom port Dbug::send([ 'event' => 'order.completed', 'order' => [ 'id' => 98765, 'amount' => 49.99, ], ]);
Laravel Log Intergration
If you are using Laravel, you can easily integrate the dbug SDK into your logging system. You can create a custom log channel in your config/logging.php file:
<?php return [ // ... 'channels' => [ // ... 'dbug' => [ 'driver' => 'custom', 'via' => App\Log\DbugLogChannel::class, ], ], ];
Then, create the DbugLogChannel class in your app/Log directory:
app/Log/DbugLogChannel.php
<?php namespace App\Log; use DbugApp\Dbug; use Monolog\Logger; use Monolog\Handler\AbstractProcessingHandler; class DbugLogChannel { /** * Create the custom Monolog logger. * * @param array $config * @return \Monolog\Logger */ public function __invoke(array $config) { $logger = new Logger('dbug'); $logger->pushHandler(new DbugHandler()); return $logger; } }
Finally, create the DbugHandler class in the same directory:
app/Log/DbugHandler.php
<?php namespace App\Log; use DbugApp\Dbug; use Monolog\Handler\AbstractProcessingHandler; use Monolog\Logger; use Monolog\LogRecord; class DbugHandler extends AbstractProcessingHandler { /** * Write a log record to Dbug. * * @param array $record * @return void */ protected function write(LogRecord $record): void { // Send the log data to Dbug Dbug::send([ 'level' => $record['level_name'], 'message' => $record['message'], 'context' => $record['context'], ]); } /** * Constructor. * * @param int $level The minimum logging level at which this handler will be triggered * @param bool $bubble Whether the messages should bubble up the stack or not */ public function __construct(int $level = Logger::DEBUG, bool $bubble = true) { parent::__construct($level, $bubble); } }
dbugapp/dbug-php 适用场景与选型建议
dbugapp/dbug-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 04 月 22 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 dbugapp/dbug-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 dbugapp/dbug-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 13
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-04-22