amphp/amp
AMPHP (AMP) accelerates PHP concurrency with fibers, eliminating callbacks and generators. Built on PHP 8.1’s cooperative coroutines, it lets you run async tasks like sync code—ideal for I/O-bound apps. Use Amp\async() for parallel execution and Future::await() to handle results seamlessly. No event...
str_increment() to fix PHP 8.5 deprecation by @nicolas-grekas in https://github.com/amphp/amp/pull/457Full Changelog: https://github.com/amphp/amp/compare/v2.6.4...v2.6.5
weakClosure() signature by @vudaltsov in https://github.com/amphp/amp/pull/452str_increment() to fix PHP 8.5 deprecation by @nicolas-grekas in https://github.com/amphp/amp/pull/456Full Changelog: https://github.com/amphp/amp/compare/v3.1.0...v3.1.1
Interval by @trowski in https://github.com/amphp/amp/pull/441__unserialize method to ForbidSerialization to guard against malicious payloads unserializing to forbidden class instances.Full Changelog: https://github.com/amphp/amp/compare/v3.0.2...v3.1.0
Closure(mixed...) annotation to Closure(...) to support PHPStan.Full Changelog: https://github.com/amphp/amp/compare/v3.0.1...v3.0.2
Amp\weakClosure() with changes made to closure names in PHP 8.4.Full Changelog: https://github.com/amphp/amp/compare/v3.0.0...v3.0.1
Full Changelog: https://github.com/amphp/amp/compare/v2.6.3...v2.6.4
Full Changelog: https://github.com/amphp/amp/compare/v2.6.2...v2.6.3
Amp no longer ships its own event loop. It's now based on Revolt. Revolt\EventLoop is quite similar to Amp's previous Amp\Loop. A very important difference is using float $seconds instead of int $milliseconds for timers though!
Future is a replacement for the previous Promise.
There's no need for callbacks or yield anymore!
Its await() method is based on fibers and replaces generator based coroutines / Amp\Promise\wait().
Amp\Deferred to Amp\DeferredFuture.Amp\Promise\wait(): Use Amp\Future::await() instead, which can be called in any (nested) context unlike before.Amp\call(): Remove the passed closure boilerplate and all yield keywords, interruption is handled via fibers now instead of generator coroutines.Amp\asyncCall(): Replace invocations with Amp\async(), which starts a new fiber instead of using generators.Amp\coroutine(): There's no direct replacement.Amp\asyncCoroutine(): There's no direct replacement.Amp\Promise\timeout(): Future::await() accepts an optional Cancellation, which can be used as a replacement.Amp\Promise\rethrow(): Unhandled errors are now automatically thrown into the event loop, so there's no need for that function anymore.Future::ignore() if needed, but should usually be handled in some way.Amp\Promise\wrap(): Use Future::finally() instead.Amp\getCurrentTime() to Amp\now() returning the time in seconds instead of milliseconds.Amp\delay() to accept the delay in seconds now instead of milliseconds.Amp\weakClosure() to allow a class to hold a self-referencing Closure without creating a circular reference that prevents automatic garbage collection.Amp\trapSignal() to await one or multiple signals.Promise combinators have been renamed:
Amp\Promise\race() has been renamed to Amp\Future\awaitFirst()Amp\Promise\first() has been renamed to Amp\Future\awaitAny()Amp\Promise\some() has been renamed to Amp\Future\awaitAnyN()Amp\Promise\any() has been renamed to Amp\Future\awaitAll()Amp\Promise\all() has been renamed to Amp\Future\await()CancellationToken has been renamed to Cancellation.CancellationTokenSource has been renamed to DeferredCancellation.NullCancellationToken has been renamed to NullCancellation.TimeoutCancellationToken has been renamed to TimeoutCancellation.CombinedCancellationToken has been renamed to CompositeCancellation.SignalCancellation has been added.Iterators have been removed from amphp/amp as normal PHP iterators can be used with fibers now and there's no need for a separate API.
However, there's still some need for concurrent iterators, which is covered by the new amphp/pipeline library now.
Amp\Closable has been added as a new basic interface for closable resources such as streams or sockets.
Strict types now declared in all library files.
This will affect callbacks invoked within this library's code which use scalar types as parameters.
Functions used with Amp\async() are the most likely to be affected by this change — these functions will now be invoked within a strict-types context.
amphp/phpunit-util (#408).UnhandledFutureError which is defined only when assertions are enabled (#405).Amp\async() are the most likely to be affected by this change — these functions will now be invoked within a strict-types context.async() closure execution (https://github.com/amphp/amp/pull/395)Future::ignore() to be a fluent interface (https://github.com/amphp/amp/pull/403)Full Changelog: https://github.com/amphp/amp/compare/v3.0.0-beta.9...v3.0.0-beta.10
async() on exceptions (https://github.com/amphp/amp/issues/394)Amp\Future\race → Amp\Future\awaitFirstAmp\Future\any → Amp\Future\awaitAnyAmp\Future\some → Amp\Future\awaitAnyNAmp\Future\settle → Amp\Future\awaitAllAmp\Future\all → Amp\Future\awaitweakClosure() not preserving scope when using a Closure with scope limited to a parent class (#393)CompositeCancellation would return false from isRequested() and not throw from throwIfRequested() after cancellation was requestedSignalCancellation that triggers a cancellation when a particular signal is received by the process.CombinedCancellation where subsequent cancellation of another Cancellation in the set could alter the exception used to cancel the token.ForbidCloning and ForbidSerialization traits as a convenient way to forbid cloning and/or serialization in a class.Closable interface for closable resources such as streams (the interface of the same name will be removed from amphp/byte-stream in a future release) (#387)CombinedCancellationToken (#384)Note: This is a pre-release, there might be breaking changes in the final stable version.
Future template parameter as covariantrevolt/event-loop v0.2.xUnhandledFutureErrorDeferredCancellation when destroyed (#382)CompositeLengthException (#383)
race → awaitFirstany → awaitAnysome → awaitAnyNsettle → awaitAllall → awaitNote: This is a pre-release, there might be breaking changes in the final stable version.
Amp\async (#379)Note: This is a pre-release, there might be breaking changes in the final stable version.
revolt/event-loop dependency declaration to use released ^0.1 version.Note: This is a pre-release, there might be breaking changes in the final stable version.
Amp no longer ships its own event loop. It's now based on Revolt. Revolt\EventLoop is quite similar to Amp's previous Amp\Loop. A very important difference is using float $seconds instead of int $milliseconds for timers.
Future is a replacement for the previous Promise. It's await() method is based on fibers and replaces generator based coroutines / Amp\Promise\wait().
await() accepts an optional Cancellation, which can be used as a replacement for Amp\Promise\timeout().Amp\Promise\rethrow() anymore.Future::ignore().CancellationToken has been renamed to CancellationCancellationTokenSource has been renamed to DeferredCancellationNullCancellationToken has been renamed to NullCancellationTimeoutCancellationToken has been renamed to TimeoutCancellationCombinedCancellationToken has been renamed to CompositeCancellationEventDriver (#358)EventDriver feature configuration to work with different kinds of FDs, e.g. under certain conditions in docker containers (#360)Deferred::isResolved()stream_select errors due to signal interruptions (#338)
Fixes stream_select handling on signal interruptions on PHP 8 and
avoids suppressing errors that shouldn't be suppressed.NativeDriver could result in timers being executed out of order (#332)NativeDriver when only signal watchers were enabledAmp\Iterator\discard() (#315)NativeDriver that are disabled and re-enabled during callback invocation (#325)Loop::now() / Driver::now() is no longer cached in each tickDelayed::reference() / Delayed::unreference() after the promise resolvedDelayed::reference() / Delayed::unreference() to self to allow fluid API usageAmp\Promise\waitAmp\call / Amp\coroutineAmp\callDeferred::resolve() (#307)stream_select() fails but error_get_last() returns null.getCurrentTime() as public API, providing millisecond timestamps for runtime measurements with special support for 32 bit systems. Returned timestamps are relative to an arbitrary point in time, so this API is only suitable to compare two timestamps generated in the same process.How can I help you explore Laravel packages today?