PHPackages                             purplepixie/php-ping - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. purplepixie/php-ping

ActiveLibrary[HTTP &amp; Networking](/categories/http)

purplepixie/php-ping
====================

PHP ICMP/Ping Network Client

1.01.0(2y ago)1139↑1400%[2 issues](https://github.com/purplepixie/php-ping/issues)GPL-3.0-onlyPHPPHP &gt;=7.0

Since Nov 7Pushed 2y ago1 watchersCompare

[ Source](https://github.com/purplepixie/php-ping)[ Packagist](https://packagist.org/packages/purplepixie/php-ping)[ RSS](/packages/purplepixie-php-ping/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

php-ping
========

[](#php-ping)

PPPing, the Purplepixie PHP Ping Library is a low-level socket based ICMP ping library written by [David Cutting](https://davecutting.uk) for use within the [FreeNATS Network Monitor](https://purplepixie.org/freenats/) but now spun out as a standalone library.

Obtaining PPPing
----------------

[](#obtaining-ppping)

The easiest option is to use [composer](https://getcomposer.org) to be able to obtain the latest package via [Packagist](https://packagist.org/packages/purplepixie/php-ping) with the command:

```
composer require purplepixie/php-ping

```

Using composer you can then autoload the classes as needed.

You can also download the source directly (from a tagged release or clone the repo) and include the file `src/PurplePixie/PhpPing/PPPing.php`.

Note the `PPPing` class is in the namespace `\PurplePixie\PhpPing\PPPing`.

Using PPPing
------------

[](#using-ppping)

Once included it's very simple to use PPPing.

```
use \PurplePixie\PhpPing\PPPing;
$ping = new PPPing(); // instantiate a PPPing object
$ping->setHostname("www.google.com"); // host to ping (hostname or IP)
$result=$ping->Ping(); // perform a single ICMP ping
// Result is either a negative number (error) or 0 up which is return in ms
if ($resultstrError($result)."\n";
else
    echo "Return: ".$result." ms\n";
```

### Additional Information Available

[](#additional-information-available)

Following a ping information about the last result is available via `PPPing::getLast()` which is an associative array with keys as follows:

- set - boolean indicating if data was returned or not
- result - the result value of the ping (negative number means error, 0 or positive is return time in ms)
- ttl - the TTL of the returned packet
- hops - an estimation of the hops based on socket TTL and returned TTL (not always accurate)
- source - IP address of the return packet source (the remote system)
- destination - IP address of the destination of the return packet (local system)

### Other Options and Variables

[](#other-options-and-variables)

Various options can be read and set as needed within the `PPPing` object

- `PPPing::getHostname()` gets the remote hostname or IP
- `PPPing::setHostname($host)` sets the remote hostname or IP
- `PPPing::getTTL()` gets the TTL
- `PPPing::setTTL($ttl)` sets the TTL
- `PPPing::getTimeout()` gets the Timeout (seconds)
- `PPPing::setTimeout($timeout)` sets the Timeout (seconds)
- `PPPing::getPackage()` gets the packet package (defaults to "PPPing")
- `PPPing::setPackage($package)` sets the packet package
- `PPPing::getDebug()` gets the debug status flag (boolean)
- `PPPing::setDebug($d)` sets the debug status flag (boolean)
- `PPPing::getSequence()` gets the sequence
- `PPPing::setSequence($s)` sets the sequence
- `PPPing::getIdentity()` gets the identity used
- `PPPing::getLast()` gets the data about the last ping

Example CLI Implementation
--------------------------

[](#example-cli-implementation)

In the `bin` folder is a ping.php which can be run on the command-line to demonstrate the functionality of PPPing. Options to the `ping.php` script are:

```
Usage: php ping.php [options] hostname

Options available are as follows:

 --ttl x | -t x    Set TTL (not working with ppping yet)
 --debug | -d      Turn on debug mode and output
 --delay x         Minimum delay between pings in seconds (or decimal)
 --help | -h       Display this help and quit
 --count x | -c x  Number of times to ping (default infinity)

hostname must be a resolvable host or an IP address to ping (required)

```

###  Health Score

16

—

LowBetter than 5% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

923d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f8711337393a7079f84fdd3daaa0ccc57d7538b83f4fdf115397b9d719bebec1?d=identicon)[davecutting](/maintainers/davecutting)

---

Top Contributors

[![purplepixie](https://avatars.githubusercontent.com/u/1479871?v=4)](https://github.com/purplepixie "purplepixie (5 commits)")

### Embed Badge

![Health badge](/badges/purplepixie-php-ping/health.svg)

```
[![Health](https://phpackages.com/badges/purplepixie-php-ping/health.svg)](https://phpackages.com/packages/purplepixie-php-ping)
```

###  Alternatives

[friendsofsymfony/rest-bundle

This Bundle provides various tools to rapidly develop RESTful API's with Symfony

2.8k73.3M319](/packages/friendsofsymfony-rest-bundle)[php-http/discovery

Finds and installs PSR-7, PSR-17, PSR-18 and HTTPlug implementations

1.3k309.5M1.2k](/packages/php-http-discovery)[nyholm/psr7

A fast PHP7 implementation of PSR-7

1.3k235.4M2.4k](/packages/nyholm-psr7)[pusher/pusher-php-server

Library for interacting with the Pusher REST API

1.5k94.8M293](/packages/pusher-pusher-php-server)[spatie/crawler

Crawl all internal links found on a website

2.8k16.3M52](/packages/spatie-crawler)[react/http

Event-driven, streaming HTTP client and server implementation for ReactPHP

78126.4M414](/packages/react-http)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
