承接 masgeek/laravel-health-checker 相关项目开发

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

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

masgeek/laravel-health-checker

最新稳定版本:1.0.2

Composer 安装命令:

composer require masgeek/laravel-health-checker

包简介

Laravel health checker helper

README 文档

README

Latest Version on Packagist Laravel Version PHP Version License

A lightweight, configurable health-check endpoint for Laravel 12+.
Provides real-time diagnostics for critical services like database, cache, Redis, mail, queues, storage, and system resources.

🚀 Features

  • Modular, configurable health checks
  • JSON endpoint for integration with monitoring tools (Prometheus, Grafana, Kubernetes, etc.)
  • Built-in support for:
    • Database connection and schema checks
    • Redis availability
    • Cache read/write
    • File storage read/write
    • Queue configuration
    • Mail transport
    • Disk usage (human-readable)
    • Pending migrations
    • Environment configuration
    • Loki server health
    • Log file write access

📦 Installation

Install via Composer:

  composer require masgeek/laravel-health-checker

⚙️ Configuration

Publish the configuration file:

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

Then edit config/healthcheck.php to configure your health checks:

return [
    'core' => [
        'database' => env('HEALTHCHECK_DATABASE', true),
        'cache' => env('HEALTHCHECK_CACHE', true),
        'queue' => env('HEALTHCHECK_QUEUE', true),
        'mail' => env('HEALTHCHECK_MAIL', false),
        'migrations' => env('HEALTHCHECK_MIGRATIONS', true),
        'env-config' => env('HEALTHCHECK_ENV_CONFIG', true),
    ],
    'infrastructure' => [
        'redis' => env('HEALTHCHECK_REDIS', false),
        'storage' => env('HEALTHCHECK_STORAGE', true),
        'disk-space' => env('HEALTHCHECK_DISK_SPACE', true),
        'logging' => env('HEALTHCHECK_LOGGING', true),
        'loki' => env('HEALTHCHECK_LOKI', false),
    ],
    'services' => [
        'loki_url' => env('LOKI_URL', null),
    ],
];

Each key corresponds to a built-in health check.

Disable what you don’t need by setting it to false.

🧠 Usage

A new route will be automatically registered:

  GET /health

Example response

{
  "status": "healthy",
  "timestamp": "2025-10-07T10:00:00Z",
  "checks": {
    "database": {
      "status": "UP",
      "database": "fuelrod",
      "schema": "public",
      "total_tables": 54
    },
    "redis": {
      "status": "UP",
      "version": "7.2.4"
    },
    "disk-space": {
      "status": "UP",
      "total_space": "500 GB",
      "free_space": "230 GB",
      "used_percentage": "54%"
    }
  }
}

🧩 Customization

  • To disable specific checks, update config/healthcheck.php.

  • To check Loki server health, define LOKI_URL in .env:

LOKI_URL=http://loki:3100

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-10-08