PHPackages                             ofbeaton/db-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. [Database &amp; ORM](/categories/database)
4. /
5. ofbeaton/db-ping

ActiveProject[Database &amp; ORM](/categories/database)

ofbeaton/db-ping
================

Verify a Database server is responding.

1.0.0(9y ago)6181[6 issues](https://github.com/ofbeaton/db-ping/issues)MITPHPPHP &gt;=5.6.0

Since Aug 5Pushed 7y ago1 watchersCompare

[ Source](https://github.com/ofbeaton/db-ping)[ Packagist](https://packagist.org/packages/ofbeaton/db-ping)[ Docs](https://github.com/ofbeaton/db-ping)[ RSS](/packages/ofbeaton-db-ping/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (7)Dependencies (6)Versions (8)Used By (0)

db-ping
=======

[](#db-ping)

db-ping verifies a database server is responding by executing a query in a timed loop.

[![Latest Stable Version](https://camo.githubusercontent.com/02b5dfe7b7e05710747b5cb54a5f00f267df12f3175ab29c3b8ae4a4f850c649/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6f66626561746f6e2f64622d70696e672e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ofbeaton/db-ping)[![Minimum PHP Version](https://camo.githubusercontent.com/86e7d829a466cacd5658a22073e27d49d39dac72cc18216ac4963ed5463c5bbc/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344253230352e362d3838393242462e7376673f7374796c653d666c61742d737175617265)](https://php.net/)[![Build Status](https://camo.githubusercontent.com/1c0a16135d8d039da012301ae48acebbc5f1c2021051f09adc12ac3637a3cbfa/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6f66626561746f6e2f64622d70696e672f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/ofbeaton/db-ping)

Optionally includes slave replication checks.

PHP 5.6+ console command that uses PDO to provide the database drivers:

- MySQL
- ODBC (i.e. Microsoft SQL Server ...)

Updates
-------

[](#updates)

The project is considered in a usable state and feature complete.

This project is used in corporate applications. As such, the authors are unlikely to update it on a regular basis, but instead when the corporate applications that use it run into problems. You should expect updates in the 5-10yr range.

Issues and PRs will be monitored, and we will continue to work with the community to provide updates as they are contributed.

Installing via phar
-------------------

[](#installing-via-phar)

Before proceeding, you need a working PHP 5.6+ installation.

The recommended way to install db-ping is by downloading the phar.

See [Releases](https://github.com/ofbeaton/db-ping/releases) for downloads.

Next, run the phar from the command line:

```
php db-ping.phar help

php db-ping.phar mysql --pass=mysecretpassword

php db-ping.phar ODBC -d OdbcName -u user -p password
```

Testing
-------

[](#testing)

### Smoke test

[](#smoke-test)

If there is no mysql server running locally, pinging will give a `connection refused` error as below

```
$ php bin/db-ping mysql
DB-PING 127.0.0.1:3306
from 127.0.0.1:3306: connection refused. delay=2000ms, exec=0ms, since success=0s, since fail=0s
from 127.0.0.1:3306: connection refused. delay=2000ms, exec=0ms, since success=0s, since fail=2.0006s
```

### Against a real MySql server

[](#against-a-real-mysql-server)

Launch a temporary mysql server:

`docker run --name some-mysql --rm -e MYSQL_ROOT_PASSWORD=my-secret-pw -e MYSQL_USER=user -e MYSQL_PASSWORD=pass -p 3306:3306 mysql`

Wait a few seconds while it initializes, then open another terminal and ping it:

```
$ php bin/db-ping mysql -u user -p pass
DB-PING 127.0.0.1:3306
from 127.0.0.1:3306: connected. delay=2000ms, exec=0ms, since success=0s, since fail=0s
from 127.0.0.1:3306: check passed. delay=2000ms, exec=0ms, since success=0s, since fail=0s
from 127.0.0.1:3306: check passed. delay=2000ms, exec=0ms, since success=2.0022s, since fail=0s
from 127.0.0.1:3306: check passed. delay=2000ms, exec=0ms, since success=4.0028s, since fail=0s
```

To stop the dockerfile: `docker stop some-mysql`

### Against a real database server via ODBC

[](#against-a-real-database-server-via-odbc)

1. Set up your php server for [ODBC](http://php.net/manual/en/ref.pdo-odbc.php)
2. Add the server you'd like to test against to the `/etc/odbc.ini` file (on linux)
3. Ping it

```
$ php bin/db-ping ODBC -d MarketflowAcc -u rou -p rou
DB-PING odbc:MarketflowAcc
from odbc:MarketflowAcc: connected. delay=2000ms, exec=0ms, since success=0s, since fail=0s
from odbc:MarketflowAcc: check passed. delay=2000ms, exec=0ms, since success=0s, since fail=0s
from odbc:MarketflowAcc: check passed. delay=2000ms, exec=0ms, since success=2.0058s, since fail=0s
from odbc:MarketflowAcc: check passed. delay=2000ms, exec=0ms, since success=4.0071s, since fail=0s
from odbc:MarketflowAcc: check passed. delay=2000ms, exec=0ms, since success=6.0083s, since fail=0s
```

The ping SQL query can be repeated more than once per ping with the `repeat` option. This is useful to make the ping test more stressful:

```
$ php bin/db-ping ODBC -d MarketflowAcc -u rou -p rou --repeat 100
```

The output format can be controlled with the `format` option:

```
$ php bin/db-ping ODBC -d MarketflowAcc -u rou -p rou --repeat 100 --format te
DB-PING odbc:MarketflowAcc
2017-01-11 14:55:35, 0
2017-01-11 14:55:35, 3
2017-01-11 14:55:37, 3
2017-01-11 14:55:39, 3
2017-01-11 14:55:41, 3
```

Also, `et` instead of `te` would shuffle the order

### Unit tests

[](#unit-tests)

Run `vbin/phing check`

License
-------

[](#license)

This software is distributed under the MIT License. Please see [License file](LICENSE) for more information.

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 61.5% 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 ~32 days

Recently: every ~48 days

Total

7

Last Release

3425d ago

Major Versions

0.3.1 → 1.0.02017-02-12

### Community

Maintainers

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

---

Top Contributors

[![ofbeaton](https://avatars.githubusercontent.com/u/1781089?v=4)](https://github.com/ofbeaton "ofbeaton (24 commits)")[![shadiakiki1986](https://avatars.githubusercontent.com/u/8392324?v=4)](https://github.com/shadiakiki1986 "shadiakiki1986 (15 commits)")

---

Tags

mysql-serverodbcphppingsql-serverdatabasemysqldbping

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

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

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

###  Alternatives

[fpdo/fluentpdo

FluentPDO is a quick and light PHP library for rapid query building. It features a smart join builder, which automatically creates table joins.

922249.3k8](/packages/fpdo-fluentpdo)[rah/danpu

Zero-dependency MySQL dump library for easily exporting and importing databases

62414.3k11](/packages/rah-danpu)[smrtr/mysql-version-control

A crude version control system for mysql written in php

221.4k](/packages/smrtr-mysql-version-control)[davmixcool/php-dbcloud

Easily backup PostgreSql or MySql database to the cloud

111.5k](/packages/davmixcool-php-dbcloud)

PHPackages © 2026

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