Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on May 9, 2024 via composer

amphp/amp v3.0.0

A non-blocking concurrency framework for PHP applications.
Package summary
Share
0
issues
1
license
2
MIT
Package created
24 Sep 2014
Version published
18 Dec 2022
Maintainers
3
Total deps
2
Direct deps
1
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
2 Packages, Including:
amphp/amp@v3.0.0
revolt/event-loop@v1.0.6
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

1
All Dependencies CSV
ⓘ This is a list of amphp/amp 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities
revolt/event-loopv1.0.635.61 kBMIT
prod

Visualizations

Frequently Asked Questions

What does amphp/amp do?

"amphp/amp" is a non-blocking concurrency framework designed to enable asynchronous programming in PHP applications. It uses the fundamental primitives of futures and cancellations along with modern fiber concepts shipped with PHP 8.1. The package alleviates the need for generator-based coroutines or callbacks used in traditional synchronous PHP models; instead, it provides an efficient way to utilize time usually spent waiting for I/O operations by performing concurrent tasks. With the use of the Amp\async() function, "amphp/amp" runs things concurrently, making it a valuable package for developers seeking to improve the performance and responsiveness of their PHP applications.

How do you use amphp/amp?

To use "amphp/amp", you start by installing it via Composer with the command: composer require amphp/amp. This makes the "amphp/amp" API readily available in your PHP application. Using "amphp/amp" is as simple as making use of its Amp\async() function to run tasks concurrently. There’s no necessity for generator-based coroutines or callbacks as you write code almost like synchronous or blocking code. For example:

<?php

use function Amp\delay;

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

Amp\async(function () {
    print '++ Executing callback passed to async()' . PHP_EOL;

    delay(3);

    print '++ Finished callback passed to async()' . PHP_EOL;
});

print '++ Suspending to event loop...' . PHP_EOL;
delay(5);

print '++ Script end' . PHP_EOL;

The package also provides other functionalities like awaiting HTTP responses concurrently using Future\await(), creating DeferredFuture, and allowing manual operation cancellations using DeferredCancellation::cancel(). Futures can be created by calling Amp\async() which runs a function as a coroutine in a different Fiber.

Where are the amphp/amp docs?

The documentation for "amphp/amp" is hosted within the README file on its GitHub page at https://github.com/amphp/amp. It provides a comprehensive guide covering the motivation behind the package, installation, functionalities, usage examples, as well as information on versioning, security, and license. For further references to understand the underlying concepts, you can explore its links to other resources like "Revolt", "Fibers", and the "Hello World example" provided within the guide.