Download the PHP package spatie/ping without Composer
On this page you can find all versions of the php package spatie/ping. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package ping
Short Description Run an ICMP ping and get structured results
License MIT
Homepage https://github.com/spatie/ping
Informations about the package ping
🏓 Run an ICMP ping and get structured results
This package provides a simple way to execute ICMP ping commands and parse the results into structured data. It wraps the system's ping command and returns detailed information about packet loss, response times, and connectivity status.
Support us
We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.
We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.
Installation
You can install the package via Composer:
Usage
The simplest way to ping a host:
Configuring ping options
You can customize the ping behavior using constructor parameters:
Or use the fluent interface:
Lost packet reporting
The showLostPackets
option enables the -O
flag on Linux systems, which reports outstanding ICMP ECHO replies before sending the next packet. This is useful for diagnostic purposes and logging when investigating network connectivity issues:
Output example
With showLostPackets: true
(default), the raw output will include notifications about missing replies:
With showLostPackets: false
, only successful replies are shown:
Note: This option only works on Linux systems and is automatically ignored on macOS.
Working with results
The PingResult
object provides detailed information about the ping operation:
Converting to array
You can convert the result to an array for easy serialization:
You can also reconstruct a PingResult
from an array:
Error handling
The error()
method on a PingResult
will return a case of the Spatie\Ping\Enums\PingError
enum.
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Freek Van der Herten
- All Contributors
License
The MIT License (MIT). Please see License File for more information.