PHPackages                             pifeifei/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. pifeifei/ping

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

pifeifei/ping
=============

A PHP class to ping hosts.

v2.0.1(3y ago)0191MITPHPPHP ^7.4|^8.0

Since Jan 31Pushed 3y agoCompare

[ Source](https://github.com/pifeifei/Ping)[ Packagist](https://packagist.org/packages/pifeifei/ping)[ RSS](/packages/pifeifei-ping/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (4)Versions (18)Used By (0)

[![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.

Usage
-----

[](#usage)

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

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

...or using the `setHost()`, `setTtl()`, `setTimeout()` or `setPort()` methods:

```
$ping = new Ping();
$ping->setHost($host)
     ->setTtl(128)
     ->setTimeout(5)
     ->setPort(80)
     ->ping();
```

You can also use it as a function call:

```
$ping = new Ping();
...
$ping('www.anotherexample.com');
$ping('example2.com');
```

License
-------

[](#license)

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

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity77

Established project with proven stability

 Bus Factor1

Top contributor holds 60.2% 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 ~196 days

Recently: every ~278 days

Total

17

Last Release

1344d ago

Major Versions

v1.2.5 → v2.0.02022-08-27

### Community

Maintainers

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

---

Top Contributors

[![geerlingguy](https://avatars.githubusercontent.com/u/481677?v=4)](https://github.com/geerlingguy "geerlingguy (50 commits)")[![pifeifei](https://avatars.githubusercontent.com/u/45787170?v=4)](https://github.com/pifeifei "pifeifei (21 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)")[![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)")[![adduc](https://avatars.githubusercontent.com/u/44527?v=4)](https://github.com/adduc "adduc (1 commits)")

---

Tags

pingphp-ping

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[shitoudev/phone-location

location of phone number

15890.4k](/packages/shitoudev-phone-location)[oh4d/laravel-accessibility

1114.3k](/packages/oh4d-laravel-accessibility)[hiraku/xml_builder

Simple DSL for building XML

141.6k1](/packages/hiraku-xml-builder)

PHPackages © 2026

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