Stu Mason
Stu Mason

Activity

Pull Request Merged

PR #1 merged: feat: Phase 2 - Health, Stats, Queue, and Artisan endpoints

Summary

This PR implements Phase 2 of laravel-kick, adding four new service + controller pairs for comprehensive remote introspection:

Health Endpoint (GET /kick/health)

  • Database connectivity check with latency
  • Cache read/write verification with latency
  • Storage read/write verification with latency
  • Redis check (when used separately from cache)
  • Returns 200 for healthy, 503 for unhealthy
  • Scope: health:read

Stats Endpoint (GET /kick/stats)

  • CPU stats (cgroups v2/v1 or system fallback)
  • Memory stats (cgroups v2/v1 or system fallback)
  • Disk usage with percentages
  • System and PHP uptime
  • Scope: stats:read

Queue Endpoints

  • GET /kick/queue - Overview with job counts per queue (scope: queue:read)
  • GET /kick/queue/failed - List failed jobs with truncated exceptions (scope: queue:read)
  • POST /kick/queue/retry/{id} - Retry specific job (scope: queue:retry)
  • POST /kick/queue/retry-all - Retry all failed jobs (scope: queue:retry)
  • Auto-detects Horizon queue configuration

Artisan Endpoints

  • GET /kick/artisan - List whitelisted commands (scope: artisan:list)
  • POST /kick/artisan - Execute command with options (scope: artisan:execute)
  • Command whitelist enforced via config/kick.php
  • Throws CommandNotAllowedException for security

Files Changed

New Services:

  • src/Services/HealthChecker.php
  • src/Services/StatsCollector.php
  • src/Services/QueueInspector.php
  • src/Services/ArtisanRunner.php

New Controllers:

  • src/Http/Controllers/HealthController.php
  • src/Http/Controllers/StatsController.php
  • src/Http/Controllers/QueueController.php
  • src/Http/Controllers/ArtisanController.php

New Exception:

  • src/Exceptions/CommandNotAllowedException.php

Updated:

  • routes/api.php - All new routes with scopes
  • composer.json - PHPStan memory limit fix

Test Plan

  • 94 tests passing (277 assertions)
  • PHPStan level 5 clean
  • Unit tests for all services
  • Feature tests for all controllers
  • Auth/scope tests for all endpoints
+2102
additions
-5
deletions
20
files changed