PHPackages                             xwp/wait-for - 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. xwp/wait-for

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

xwp/wait-for
============

0.0.2(2y ago)0116.2k—8.5%1PHP

Since May 17Pushed 2y ago1 watchersCompare

[ Source](https://github.com/xwp/io-php-wait-for)[ Packagist](https://packagist.org/packages/xwp/wait-for)[ RSS](/packages/xwp-wait-for/feed)WikiDiscussions main Synced 3d ago

READMEChangelogDependenciesVersions (3)Used By (1)

"Wait For" Helper for PHP
=========================

[](#wait-for-helper-for-php)

Wait for TCP connections to services with a timeout. Useful when waiting for services on Docker containers that take a while to start such as MySQL.

Usage
-----

[](#usage)

Require this library as a development dependency for your project:

```
composer require --dev xwp/wait-for

```

Use it in your project to wait for a TCP response from `localhost:3306`:

```
// Include the Composer autoloader.
require_once __DIR__ . '/vendor/autoload.php';

$connection = new XWP\Wait_For\Tcp_Connection( 'localhost', 3306 );

try {
	$connection->connect( 30 );
} catch ( Exception $e ) {
	trigger_error( $e->getMessage(), E_USER_ERROR );
}
```

where `locahost` is the hostname, `3306` is the port number and `30` is the timeout in seconds.

Design Decisions
----------------

[](#design-decisions)

- Use PHP exceptions on connection errors to ensure that applications relying on process return codes are made aware of the connection error.

Examples
--------

[](#examples)

Use the included helpers to create your own waiting logic:

```
use XWP\Wait_For\With_Retry;

$runner = new With_Retry(
	function() {
		// Do something here.
		return false;
	}
);

if ( ! $runner->run( 10 ) ) {
	trigger_error( 'Failed to connect!' );
}
```

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity31

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

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 ~558 days

Total

2

Last Release

950d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/169055?v=4)[Kaspars Dambis](/maintainers/kasparsd)[@kasparsd](https://github.com/kasparsd)

![](https://www.gravatar.com/avatar/415bc53586018077324af64dad074bf430ba1b72471550489372668274a13b12?d=identicon)[xwp](/maintainers/xwp)

### Embed Badge

![Health badge](/badges/xwp-wait-for/health.svg)

```
[![Health](https://phpackages.com/badges/xwp-wait-for/health.svg)](https://phpackages.com/packages/xwp-wait-for)
```

PHPackages © 2026

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