承接 jdz/monitor 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

jdz/monitor

最新稳定版本:1.0.3

Composer 安装命令:

composer require jdz/monitor

包简介

JDZ html formatter for debug

README 文档

README

Formatted HTML monitoring output for PHP processes. Build structured HTML reports (headings, paragraphs, lists, boxes, preformatted blocks) to display in a browser or send by email via jdz/mailer.

Installation

composer require jdz/monitor

Requirements

  • PHP >= 8.2

Usage

Basic Example

use JDZ\Monitor\Monitor;

$monitor = new Monitor();

$monitor->h1('Process Report');
$monitor->p('Process completed successfully.');
$monitor->p('42 items processed', 'Total');

echo (string)$monitor;

Headings

$monitor->h1('Title');      // <h1>
$monitor->h2('Subtitle');   // <h2>
// ... up to h6()

Paragraphs

// Simple paragraph
$monitor->p('Some text');

// With a bold label prefix
$monitor->p('150ms', 'Duration');
// Output: <p><strong>Duration</strong>: 150ms</p>

// With inline style
$monitor->p('All good', 'Status', 'color:green;');

Lists

$monitor->list([
    'Step 1: Data fetched',
    'Step 2: Data validated',
    'Step 3: Data imported',
]);

Preformatted Content

// String (newlines are converted to <br />)
$monitor->pre("line 1\nline 2");

// Or an array of lines
$monitor->pre(['line 1', 'line 2']);

Colored Boxes

// Simple string box
$monitor->box('Some content', '#E8F5E9', '#1B5E20');

// Mixed content box with structured objects
$monitor->box([
    (object)['h' => 'Details', 'level' => 3],
    (object)['content' => '150ms', 'label' => 'Duration'],
    (object)['pre' => "SELECT * FROM users"],
    (object)['list' => ['cache: HIT', 'db: 2 queries']],
    'Plain string line',
]);

Raw HTML

$monitor->addHtmlString('<hr/>');

Checking for Content

if ($monitor->hasContent()) {
    $html = (string)$monitor;
}

Sending by Email

Pair with jdz/mailer to email the report:

use JDZ\Monitor\Monitor;
use JDZ\Mailer\Mailer;

$monitor = new Monitor();
$monitor->h1('Cron Report');
$monitor->p('Everything OK');

$mail = new Mailer();
$mail->setContent([
    'isHtml' => true,
    'content' => (string)$monitor,
]);
$mail->addRecipient('admin@example.com');
$mail->set('subject', 'Cron Report');
$mail->send();

Fluent Interface

All content methods return $this, so calls can be chained:

$monitor
    ->h1('Report')
    ->p('All systems operational')
    ->list(['API: OK', 'DB: OK', 'Cache: OK'])
    ->box('No errors', '#E8F5E9', '#1B5E20');

Testing

composer test
# or
vendor/bin/phpunit

License

This project is licensed under the MIT License - see the LICENSE file for details.

统计信息

  • 总下载量: 16
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-12-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固