smartassert/service-status-inspector
Service Status Inspector is a PHP package for checking the availability and health of external services. Use it to verify dependencies are reachable, surface outages early, and help tests and applications respond gracefully when a service goes down.
This is a standalone PHP library, not a Laravel package — there is no service provider, facade, or config file to publish. Add it with composer require smartassert/service-status-inspector:^6.0 (requires PHP 8.2+, which 6.0 enforces).
Look first at:
vendor/smartassert/service-status-inspector/README.md — the canonical usage example.src/ — the inspector entry point and the value objects it returns (status + collection types). These are the only surfaces you'll typically touch.composer.json — confirm the PSR-18/PSR-17 dependency constraints so your app's HTTP client version doesn't conflict.First use case: a health-check command that takes a list of URLs your app depends on (payment gateway, internal APIs, search cluster) and reports which are reachable. Construct the inspector with an HTTP client, pass the URLs, iterate the returned statuses, and exit non-zero if anything is down.
Construct the inspector from the container. Because the library expects a PSR-18 client (and PSR-17 factories for request creation), bind them in a service provider rather than new-ing Guzzle inline. Laravel's Illuminate\Http\Client is not PSR-18, so either resolve Guzzle from the container or use psr18 adapters — decide once and register a singleton.
Wrap it in an Artisan command, not a controller. php artisan services:status is the idiomatic entry point: build the URL list from config('services.monitored'), run the inspection, format a table with $this->table(), and return self::FAILURE when any status is not up. This makes it usable from cron, CI, and manually.
Schedule it and cache the result. Put the command on Schedule::command('services:status')->everyFiveMinutes() and write the outcome to the cache. Expose a cheap /health route that reads the cache instead of performing live HTTP calls on every request — you do not want a monitoring page that fan-outs to ten endpoints per hit.
Use the result objects, don't re-implement parsing. The returned status objects carry the URL and the availability outcome; treat them as an immutable DTO layer. Map them into your own array/JSON shape at the boundary (command output, API response) rather than leaking library types into controllers or jobs.
Fan out with a job for large URL sets. The inspector is synchronous. For dozens of endpoints, dispatch one CheckServiceStatus job per URL with Bus::batch() and aggregate, so a single slow host does not stall the whole run. Use Http::timeout()/client-level timeouts to bound each call.
Gate deployments on it. In CI or a deploy pipeline, run the command after migrations and before traffic switch; a non-zero exit is a natural readiness gate.
ClientInterface fails loudly; passing a Laravel HTTP client wrapper silently won't exist. Pin the adapter in one place.ClientExceptionInterface around the inspection call (or per-URL if you fan out) and translate exceptions into a "down" result yourself — otherwise a single unreachable host can abort the whole report.retry() or your own backoff if you're monitoring flaky third parties; the library reports one observation per run.config/services.php + env overrides lets ops change targets without a deploy, and it keeps the package usage trivially testable.How can I help you explore Laravel packages today?