baklysystems/app-watch-laravel-client 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

baklysystems/app-watch-laravel-client

Composer 安装命令:

composer require baklysystems/app-watch-laravel-client

包简介

Self-hosted Laravel monitoring — client package for automatic telemetry collection (exceptions, logs, queries, queues, schedules, HTTP requests, metrics, MySQL health)

README 文档

README

A lightweight, zero-config Composer package that automatically collects telemetry from any Laravel application and sends it to your self-hosted Appswatch monitoring server.

What It Captures

Surface Method Details
Exceptions Event listener Captures all unhandled + logged exceptions with stack traces, breadcrumbs, severity mapping
Logs Monolog handler Batches log entries (level, context, channel, trace ID)
Database Queries DB::listen() SQL, bindings, duration, slow query detection
Queue Jobs Job events Processing/completed/failed with attempt tracking and timing
Scheduled Tasks Schedule events Start/completed/failed with output capture and duration
HTTP Requests Middleware Method, URL, status code, duration, memory, request body (masked)
Custom Metrics Static collector Gauge, counter, histogram via MetricCollector
MySQL Health SHOW STATUS Connections, buffer pool, QPS, replication lag, key cache

Installation

composer require baklysystems/app-watch-laravel-client

Laravel auto-discovery registers the service provider and facade automatically. No manual configuration needed.

Configuration

Publish the config file:

php artisan vendor:publish --tag=appswatch-config

Set these environment variables in your .env:

APPSWATCH_SERVER_URL=https://your-appswatch-instance.com
APPSWATCH_API_KEY=your-project-api-key
APPSWATCH_ENABLED=true
APPSWATCH_ENVIRONMENT=production
APPSWATCH_RELEASE=v1.2.3

Usage

Automatic: Everything is captured automatically once the package is installed and configured.

Manual / programmatic (uses the Facade):

use Appswatch;

// Log a custom event
Appswatch::log('info', 'User signed up', ['user_id' => 42]);

// Capture an exception manually
try {
    riskyOperation();
} catch (\Throwable $e) {
    Appswatch::exception($e, ['user_id' => $userId]);
}

// Send a custom metric
Appswatch::metric('users.signed_up', 1, 'count', ['plan' => 'pro']);

Custom Job Middleware

Wrap any queued job to capture timing and failures:

use BaklySystems\AppWatch\Middleware\AppswatchJobMiddleware;

class MyJob implements ShouldQueue
{
    public function middleware(): array
    {
        return [new AppswatchJobMiddleware];
    }
}

Custom Metrics from Your Code

use BaklySystems\AppWatch\Collectors\MetricCollector;

MetricCollector::counter('orders.placed', 1, 'count', ['channel' => 'web']);
MetricCollector::gauge('users.active', 150, 'count', ['plan' => 'pro']);
MetricCollector::histogram('api.response_time_ms', 42.5, 'ms', ['endpoint' => '/api/users']);

Architecture

Your Laravel App
     │
     ▼
┌─────────────────────────────────────────────┐
│  Appswatch Package (this)                    │
│                                              │
│  ExceptionCollector ───┐                    │
│  LogCollector ──────────┤                    │
│  QueryCollector ────────┤    ┌────────────┐ │
│  QueueCollector ────────┼───▶│HttpTransport│─┼──▶ Your Appswatch Server
│  ScheduleCollector ─────┤    └────────────┘ │     /api/ingest/*
│  RequestMiddleware ─────┤         │          │
│  MetricCollector ───────┘    (buffered)     │
│  MySqlHealthCollector        retry on fail  │
└─────────────────────────────────────────────┘

Requirements

  • PHP 8.2+
  • Laravel 11.x or 12.x
  • Guzzle 7
  • Monolog 3

License

MIT. See LICENSE.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-06-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固