1
0
mirror of https://github.com/danog/amp.git synced 2024-11-26 20:15:00 +01:00
Go to file
Niklas Keller 82835325d0 Prevent ext-event 2.4.0RC1 and use 2.3.0 instead
PHP 7.2 in combination with ext-event 2.4.0RC1 throws exceptions with invalid file descriptors, while everything works fine with 2.3.0 or PHP < 7.2.

This is a temporary fix to get the build green again.

Relates to #221.
2018-04-30 22:47:14 +02:00
docs Update documentation dependencies 2018-04-30 10:48:03 +02:00
examples Fix code style 2018-01-08 22:00:15 +01:00
lib Don't record stack traces in case of AMP_DEBUG not being set (#218) 2018-04-26 00:32:31 +02:00
test Fix 212 and ignore unreference on invalid watchers (#216) 2018-04-12 09:46:52 +02:00
travis Prevent ext-event 2.4.0RC1 and use 2.3.0 instead 2018-04-30 22:47:14 +02:00
.editorconfig Fix .editorconfig 2017-07-29 22:21:50 +02:00
.gitattributes Fix example → examples in Git attributes 2017-04-16 21:58:11 +02:00
.gitignore Added further Internal\Producer tests 2017-05-02 18:10:10 +02:00
.gitmodules Update to new shared repository 2017-09-27 13:25:40 +02:00
.php_cs.dist Automatically add \ for buitins (#186) 2017-11-29 13:36:50 +01:00
.travis.yml Define AMP_DEBUG through environment 2017-12-02 10:23:12 -06:00
CHANGELOG.md Add changelog entry for 2.0.7 2018-04-30 10:43:43 +02:00
composer.json Update contributing.md 2018-03-16 15:42:32 +02:00
CONTRIBUTING.md Fix code review comments 2018-03-16 15:55:04 +02:00
LICENSE Fix copyright dates 2017-03-12 12:38:18 +01:00
Makefile Add Makefile that automatically setups, runs tests and checks code style 2017-05-04 08:44:44 +02:00
phpunit.xml.dist Fix potential issues when operating on destroyed uv handles in shutdown sequence 2017-05-16 18:17:12 +02:00
README.md Add syntax highlighting 2017-11-12 17:16:19 +01:00

Amp Logo

Amp     

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.

Installation

This package can be installed as a Composer dependency.

composer require amphp/amp

Documentation

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

Requirements

  • PHP 7.0+
Optional Extension Backends

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

Examples

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

<?php

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

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

Loop::run(function () {
    $uris = [
        "https://google.com/",
        "https://github.com/",
        "https://stackoverflow.com/",
    ];

    $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

Versioning

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

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

Compatible Packages

Compatible packages should use the amphp topic on GitHub.

Security

If you discover any security related issues, please email bobwei9@hotmail.com or me@kelunik.com instead of using the issue tracker.

License

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