PHPackages                             geerlingguy/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. geerlingguy/ping

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

geerlingguy/ping
================

A PHP class to ping hosts.

1.2.1(6y ago)4912.2M↓53.9%151[3 issues](https://github.com/geerlingguy/Ping/issues)[2 PRs](https://github.com/geerlingguy/Ping/pulls)14MITPHPCI passing

Since Jan 31Pushed 2y ago20 watchersCompare

[ Source](https://github.com/geerlingguy/Ping)[ Packagist](https://packagist.org/packages/geerlingguy/ping)[ RSS](/packages/geerlingguy-ping/feed)WikiDiscussions 1.x Synced 3d ago

READMEChangelogDependenciesVersions (10)Used By (14)

[![Ping for PHP Logo](https://raw.githubusercontent.com/geerlingguy/Ping/1.x/Resources/Ping-Logo.png)](https://raw.githubusercontent.com/geerlingguy/Ping/1.x/Resources/Ping-Logo.png)

Ping
====

[](#ping)

[![Build Status](https://camo.githubusercontent.com/e7a46dc6102296bb225b03991a231bc850c3920684a49f3f2084774715f52c70/68747470733a2f2f7472617669732d63692e6f72672f676565726c696e676775792f50696e672e7376673f6272616e63683d312e78)](https://travis-ci.org/geerlingguy/Ping)

A PHP class to ping hosts.

There are a ton of different methods of pinging a server using PHP, and I've found most to be poorly documented or downright dangerous in their implementation.

Therefore, I've created this simple class, which incorporates the three most popular ping methods (`exec()` with the system's `ping` utility, `fsockopen()`, and `socket_create()`). Each method has its benefits and drawbacks, and may work better or worse on a particular system.

Installation
------------

[](#installation)

```
$ composer require geerlingguy/ping

```

Usage
-----

[](#usage)

This is a very simple class. Just create an instance, and run `ping()`.

```
$host = 'www.example.com';
$ping = new \JJG\Ping($host);
$latency = $ping->ping();
if ($latency !== false) {
  print 'Latency is ' . $latency . ' ms';
}
else {
  print 'Host could not be reached.';
}
```

You can also specify the ttl (maximum hops) and timeout when creating the instance:

```
$ttl = 128;
$timeout = 5;
$ping = new \JJG\Ping($host, $ttl, $timeout);
```

...or using the `setTtl()` or `setTimeout()` methods:

```
$ping = new \JJG\Ping($host);
$ping->setTtl(128);
$ping->setTimeout(5);
```

You can change the host using the `setHost()` method:

```
$ping = new \JJG\Ping($host);
...
$ping->setHost('www.anotherexample.com');
```

License
-------

[](#license)

Ping is licensed under the MIT (Expat) license. See included LICENSE.md.

Author
------

[](#author)

Ping is maintained by [Jeff Geerling](https://www.jeffgeerling.com), and is used to check servers for [Server Check.in](https://servercheck.in), an inexpensive website and server uptime monitoring service.

###  Health Score

50

—

FairBetter than 95% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity63

Solid adoption and visibility

Community38

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 79.7% 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

Every ~383 days

Recently: every ~648 days

Total

10

Last Release

1089d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/481677?v=4)[Jeff Geerling](/maintainers/geerlingguy)[@geerlingguy](https://github.com/geerlingguy)

---

Top Contributors

[![geerlingguy](https://avatars.githubusercontent.com/u/481677?v=4)](https://github.com/geerlingguy "geerlingguy (55 commits)")[![strongwazz](https://avatars.githubusercontent.com/u/911315?v=4)](https://github.com/strongwazz "strongwazz (3 commits)")[![divinity76](https://avatars.githubusercontent.com/u/1874996?v=4)](https://github.com/divinity76 "divinity76 (3 commits)")[![sergiowww](https://avatars.githubusercontent.com/u/8181382?v=4)](https://github.com/sergiowww "sergiowww (2 commits)")[![szarka](https://avatars.githubusercontent.com/u/8078659?v=4)](https://github.com/szarka "szarka (1 commits)")[![adduc](https://avatars.githubusercontent.com/u/44527?v=4)](https://github.com/adduc "adduc (1 commits)")[![Wulfheart](https://avatars.githubusercontent.com/u/25671390?v=4)](https://github.com/Wulfheart "Wulfheart (1 commits)")[![marcbp](https://avatars.githubusercontent.com/u/5139232?v=4)](https://github.com/marcbp "marcbp (1 commits)")[![peec](https://avatars.githubusercontent.com/u/131546?v=4)](https://github.com/peec "peec (1 commits)")[![pixelbrackets](https://avatars.githubusercontent.com/u/1592995?v=4)](https://github.com/pixelbrackets "pixelbrackets (1 commits)")

---

Tags

classlinuxmacmacosnetwork-toolsnetworkingpackagistphppingwindows

### Embed Badge

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

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

###  Alternatives

[ecoapm/libyear

A simple measure of software dependency freshness

28306.2k](/packages/ecoapm-libyear)

PHPackages © 2026

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