PHPackages                             yogarine/wait-for-it.php - 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. yogarine/wait-for-it.php

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

yogarine/wait-for-it.php
========================

A PHP implementation of Giles Hall's wait-for-it.sh script.

1.0.2(4y ago)147.9k↓82.4%MITPHPPHP &gt;=7.0

Since Feb 9Pushed 4y ago1 watchersCompare

[ Source](https://github.com/AlwinGarside/wait-for-it.php)[ Packagist](https://packagist.org/packages/yogarine/wait-for-it.php)[ RSS](/packages/yogarine-wait-for-itphp/feed)WikiDiscussions main Synced yesterday

READMEChangelogDependenciesVersions (5)Used By (0)

wait-for-it.php
===============

[](#wait-for-itphp)

wait-for-it.php is a PHP implementation of the [wait-for-it.sh script by Gilles Hall](https://github.com/vishnubob/wait-for-it).

It can be both run as a standalone executable or included in PHP and used by calling the wait\_for\_it() function. As standalone script it can be used as a drop-in replacement for wait-for-it.sh.

Usage
-----

[](#usage)

### From the command line

[](#from-the-command-line)

```
   wait-for-it.php [: | -p ] [options] [--] [command [args]]
   wait-for-it.php -h  -p  [options] [--] [command [args]]

  -h , --host=  Host or IP under test
  -p , --port=  TCP port under test. Alternatively, you specify the
                            host and port as host:port
  -s, --strict              Only execute subcommand if the test succeeds
  -q, --quiet               Don't output any status messages
  -t , --timeout=
                            Timeout in seconds, zero for no timeout
  -- command args             Execute command with args after the test finishes

```

### From PHP:

[](#from-php)

```
function wait_for_it(string $address, int $timeout = 15, float &$time_waited = null): bool {}
```

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

[](#installation)

### As Composer package

[](#as-composer-package)

You can install it globally to use it as a stand-alone command:

```
composer global require yogarine/wait-for-it
```

You can also install wait-for-it.php as a dependency of your project:

```
composer require yogarine/wait-for-it
```

This will allow you to use the `wait_for_it()` function.

### Docker

[](#docker)

wait-for-it.php is also available as a Docker image:

```
docker run yogarine/wait-for-it www.google.com:80 -- echo "google is up"
```

You can also easily copy the script in your own Dockerfiles:

```
# Copy wait-for-it.php from it's official Docker image.
COPY --from=yogarine/wait-for-it /usr/local/bin/wait-for-it /usr/local/bin/
```

Just keep in mind you'll need to have the pcntl extension installed.

Usage in PHP code
-----------------

[](#usage-in-php-code)

When installed as composer package `wait-for-it.php` is automatically included as helper file, and declares the `wait_for_it()` function.

It will wait and return `true` if the host came up, and false otherwise.

Examples
--------

[](#examples)

For example, let's test to see if we can access port 80 on `www.google.com`, and if it is available, echo the message `google is up`.

```
$ vendor/bin/wait-for-it -t 0 www.google.com:80 -- echo "google is up" www.google.com:80 -- echo "google is up"
wait-for-it: waiting 15 seconds for www.google.com:80
wait-for-it: www.google.com:80 is available after 0 seconds
google is up
```

You can set your own timeout with the `-t` or `--timeout=` option. Setting the timeout value to 0 will disable the timeout:

```
$ vendor/bin/wait-for-it -t 0 www.google.com:80 -- echo "google is up"
wait-for-it: waiting for www.google.com:80 without a timeout
wait-for-it: www.google.com:80 is available after 0 seconds
google is up
```

The subcommand will be executed regardless if the service is up or not. If you wish to execute the subcommand only if the service is up, add the `--strict`argument. In this example, we will test port 81 on `www.google.com` which will fail:

```
$ vendor/bin/wait-for-it www.google.com:81 --timeout=1 --strict -- echo "google is up"
wait-for-it: waiting 1 seconds for www.google.com:81
wait-for-it: timeout occurred after waiting 1 seconds for www.google.com:81
wait-for-it: strict mode, refusing to execute subprocess
```

If you don't want to execute a subcommand, leave off the `--` argument. This way, you can test the exit condition of `wait-for-it.php` in your own scripts, and determine how to proceed:

```
$ vendor/bin/wait-for-it www.google.com:80
wait-for-it: waiting 15 seconds for www.google.com:80
wait-for-it: www.google.com:80 is available after 0 seconds
$ echo $?
0
$ vendor/bin/wait-for-it www.google.com:81
wait-for-it: waiting 15 seconds for www.google.com:81
wait-for-it: timeout occurred after waiting 15 seconds for www.google.com:81
$ echo $?
124
```

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 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

Every ~92 days

Total

4

Last Release

1694d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/17518a08933290f58c1665feec25cf0939d1c6413b7b4cc25ef6d965b9fcc473?d=identicon)[Alwin Garside](/maintainers/Alwin%20Garside)

---

Top Contributors

[![AlwinGarside](https://avatars.githubusercontent.com/u/193043?v=4)](https://github.com/AlwinGarside "AlwinGarside (8 commits)")

### Embed Badge

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

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

PHPackages © 2026

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