happytodev/phage-debug
Composer 安装命令:
composer require happytodev/phage-debug
包简介
Phage Debug - Built-in debugging system for PHP development
README 文档
README
Built-in debugging system for PHP development with Phage. Simple and elegant debugging tool with zero configuration.
Features
- 📝 Logging - Log messages with context
- 🔍 Collapsible Variables - Inspect variables with expandable tree view
- 🎨 Syntax Coloring - Color-coded display by type
- 📦 Object Inspection - View properties (public/protected/private)
- ⏱️ Performance Measurement - Measure execution time and memory
- 🗄️ SQL Logging - Log database queries with bindings
- ❌ Exception Handling - Capture and analyze exceptions
- 📊 Table Display - Display data as formatted tables
- 📡 HTTP Requests - Log HTTP requests and responses
- 🔄 Stack Traces - Get detailed stack traces
- ✨ Zero Configuration - Works out of the box
- 📡 Real-time Updates - Live WebSocket connection to debug UI
- 💾 Persistent History - SQLite database backend
Installation
Install via Composer:
composer require happytodev/phage-debug
Requirements
- PHP 7.4 or higher
- Phage debug server running on
http://localhost:23517(default)
Quick Start
1. Make sure the Phage debug server is running:
./phage debug:start
2. Use in your PHP code:
<?php use Phage\Debug\Debug; // Simple logging Debug::log('Application started'); Debug::log('User data', $user); // Dump variables with interactive tree view Debug::dump($_GET, $_POST, $complexArray); // Log queries Debug::sql('SELECT * FROM users', [], 0.045); // Log exceptions try { // ... } catch (Exception $e) { Debug::exception($e); } // Measure performance Debug::measure('Database Query', function() { return User::all(); }); // Display as table Debug::table($users, 'Active Users'); // Pretty-print JSON Debug::json(['status' => 'success', 'data' => $data]);
3. Open the debug UI:
./phage debug:open
Or manually open: http://localhost:23517
UI Features
The debug UI displays:
Collapsible Arrays:
▶ Array(5)
[0]: "item1"
[1]: "item2"
[id]: 123
Collapsible Objects:
▶ User(4 properties)
$id (private): 123
$name (private): "John Doe"
$email (private): "john@example.com"
$roles (protected): Array(2)
[0]: "admin"
[1]: "user"
Primitive Types:
string: "Hello World"
integer: 42
float: 3.14
boolean: true
null: null
Configuration
Configure globally in your bootstrap code:
use Phage\Debug\Debug; Debug::config([ 'enabled' => true, 'endpoint' => 'http://localhost:23517/api/payloads', 'async' => true, // Non-blocking requests 'timeout' => 0.5, // 500ms timeout ]);
Or configure individually:
Debug::setEndpoint('http://192.168.1.100:23517/api/payloads'); Debug::setOrigin('my-project');
API Reference
Logging & Dumping
Debug::log(...$messages)- Log messages with optional contextDebug::dump(...$vars)- Dump variables with full tree view
Measurement
Debug::measure($label, $callback)- Measure execution time and memoryDebug::sql($sql, $bindings, $time)- Log SQL queries with bindingsDebug::exception($throwable)- Log exceptions with stack trace
Data Display
Debug::table($data, $label)- Display data as formatted tableDebug::json($data, $label)- Pretty-print JSONDebug::http($method, $url, $headers, $body, $duration)- Log HTTP requests
Utilities
Debug::trace($label)- Get current stack traceDebug::enable()- Enable debuggingDebug::disable()- Disable debuggingDebug::isEnabled()- Check if debugging is enabled
Advanced Usage
Disable for Production
if (env('APP_DEBUG')) { Debug::enable(); } else { Debug::disable(); }
Custom Origin
// Defaults to composer.json "name" field Debug::setOrigin('my-custom-project-name');
Remote Debugging
Connect to a remote Phage debug server:
Debug::setEndpoint('http://192.168.1.100:23517/api/payloads'); Debug::log('Log from remote client');
Synchronous Mode
By default, debug requests are non-blocking (async). Force synchronous mode:
Debug::config([ 'async' => false, // Wait for responses 'timeout' => 2.0, // 2 second timeout ]);
How It Works
- Your PHP code calls
Debug::log(),Debug::dump(), etc. - The package serializes the data (arrays, objects, primitives) into a detailed structure
- A non-blocking HTTP POST request sends the data to the Phage debug server
- The server broadcasts the payload to connected WebSocket clients (the UI)
- The UI renders the data with interactive collapsible trees
- Data is also persisted in SQLite for history
Supported Types
- Primitives: null, bool, int, float, string
- Collections: array (with unlimited nesting)
- Objects: Any PHP object (with property inspection)
- Special: DateTime objects with formatted display
Recursion Limit
To prevent infinite loops with circular references, the package limits recursive depth to 10 levels. Deeper nesting is truncated with a [Max depth reached] indicator.
License
MIT License - see LICENSE file for details
Support
For issues, questions, or contributions:
- Repository: https://github.com/happytodev/phage-debug
- Packagist: https://packagist.org/packages/happytodev/phage-debug
- Issues: https://github.com/happytodev/phage-debug/issues
Author
happytodev/phage-debug 适用场景与选型建议
happytodev/phage-debug 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 8 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 02 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 happytodev/phage-debug 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 happytodev/phage-debug 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 8
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 26
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-02-07