spatie/ping
Run ICMP ping from PHP and get structured results. Spatie Ping wraps the system ping command, parsing packet loss, transmit/receive counts, min/max/avg times, standard deviation, per-line responses, and error status for quick connectivity checks.
spatie/ping package is a lightweight, focused solution for ICMP-based network reachability checks. It fits well in architectures requiring structured ping results (e.g., uptime monitoring, network diagnostics, or dependency validation) without reinventing the wheel.Cache, Queue) for retries, rate-limiting, or async processing.curl --connect-timeout). May misclassify high-latency but functional endpoints.retry helper or spatie/backtrace).HEAD requests) acceptable?artisan ping:check command for CLI-driven monitoring.spatie/queueable-model) to offload pings to workers (e.g., ping:check job).app()->bind(PingService::class, function () { ... })).spatie/laravel-activitylog or spatie/laravel-monitor for notifications.spatie/laravel-prometheus.spatie/laravel-logging for ELK/Grafana.ping -c 4) for accuracy.ping calls) with the package for consistency.spatie/ping for ICMP-capable networks, fall back to HTTP HEAD for restricted environments (custom wrapper class).ping:alpine container).composer require spatie/ping..env or a config file.use Spatie\Ping\Ping;
$ping = Ping::create()
->host('example.com')
->timeout(2) // 2 seconds
->ping();
if ($ping->successful()) {
// Handle success
}
retry:until with Laravel’s retry helper).Spatie\Logging\LoggingFacade.schedule->command('ping:check')->everyMinute()).spatie/ping for breaking changes (MIT license allows forks if needed).*.corp.internal").Ping class to dump system calls).ping -v or Wireshark for discrepancies.timeout or reduce count for resource-constrained hosts.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| ICMP blocked by firewall | False negatives in monitoring | Fallback to HTTP/TCP checks |
| High packet loss (>50%) | Alert fatigue or missed issues | Adjust thresholds or suppress known hosts |
| PHP process crashes | Lost ping data | Use Laravel Queues with dead-letter queue |
| Network congestion | Slow responses | Implement exponential backoff |
| Package deprecation | Broken functionality | Fork or migrate to alternative (e.g., symfony/process) |
PingService facade for consistency.How can I help you explore Laravel packages today?