A non-blocking concurrency framework for PHP applications.

Installs: 1 010 339

Dependents: 144

Suggesters: 2

Stars: 2 322

Watchers: 125

Forks: 136

Open Issues: 27


Amp Logo


Amp is a non-blocking concurrency framework for PHP. It provides an event loop, promises and streams as a base for asynchronous programming.

Promises in combination with generators are used to build coroutines, which allow writing asynchronous code just like synchronous code, without any callbacks.

68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f616d7068702f616d702f6d61737465722e7376673f7374796c653d666c61742d737175617265 68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f616d7068702f616d702f6d61737465722e7376673f7374796c653d666c61742d737175617265 68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e7376673f7374796c653d666c61742d737175617265


This package can be installed as a Composer dependency.

composer require amphp/amp


Documentation can be found on as well as in the ./docs directory.


  • PHP 7.0+
Optional Extension Backends

Extensions are only needed if your app necessitates a high numbers of concurrent socket connections.


This simple example uses our Artax HTTP client to fetch multiple HTTP resources concurrently.


use Amp\Artax\Response;
use Amp\Loop;

require __DIR__ . '/../vendor/autoload.php';

Loop::run(function () {
    $uris = [

    $client = new Amp\Artax\DefaultClient;
    $client->setOption(Amp\Artax\Client::OP_DISCARD_BODY, true);

    try {
        foreach ($uris as $uri) {
            $promises[$uri] = $client->request($uri);

        $responses = yield $promises;

        foreach ($responses as $uri => $response) {
            print $uri . " - " . $response->getStatus() . $response->getReason() . PHP_EOL;
    } catch (Amp\Artax\HttpException $error) {
        // If something goes wrong Amp will throw the exception where the promise was yielded.
        // The Client::request() method itself will never throw directly, but returns a promise.
        print $error->getMessage() . PHP_EOL;

Further examples can be found in the ./examples directory of this repository as well as in the ./examples directory of our other libraries


amphp/amp follows the semver semantic versioning specification like all other amphp packages.

Version Bug Fixes Until Security Fixes Until
1.x 2017-12-31 2018-12-31

Compatible Packages

Compatible packages should use the amphp topic on GitHub.


If you discover any security related issues, please email or instead of using the issue tracker.


The MIT License (MIT). Please see LICENSE for more information.