Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Amp Laravel Package

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...

View on GitHub
Deep Wiki
Context7
v2.6.5

What's Changed

Full Changelog: https://github.com/amphp/amp/compare/v2.6.4...v2.6.5

v3.1.1

What's Changed

New Contributors

Full Changelog: https://github.com/amphp/amp/compare/v3.1.0...v3.1.1

v3.1.0

What's Changed

New Contributors

Full Changelog: https://github.com/amphp/amp/compare/v3.0.2...v3.1.0

v3.0.2

What's Changed

  • Changed Closure(mixed...) annotation to Closure(...) to support PHPStan.

Full Changelog: https://github.com/amphp/amp/compare/v3.0.1...v3.0.2

v3.0.1

What's Changed

  • Fixed compatibility of 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

v2.6.4

What's Changed

  • Fix optional before required parameter deprecation

Full Changelog: https://github.com/amphp/amp/compare/v2.6.3...v2.6.4

v2.6.3

What's Changed

New Contributors

Full Changelog: https://github.com/amphp/amp/compare/v2.6.2...v2.6.3

v3.0.0

Event Loop

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!

Promises

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().

  • Renamed Amp\Deferred to Amp\DeferredFuture.
  • Removed Amp\Promise\wait(): Use Amp\Future::await() instead, which can be called in any (nested) context unlike before.
  • Removed Amp\call(): Remove the passed closure boilerplate and all yield keywords, interruption is handled via fibers now instead of generator coroutines.
  • Removed Amp\asyncCall(): Replace invocations with Amp\async(), which starts a new fiber instead of using generators.
  • Removed Amp\coroutine(): There's no direct replacement.
  • Removed Amp\asyncCoroutine(): There's no direct replacement.
  • Removed Amp\Promise\timeout(): Future::await() accepts an optional Cancellation, which can be used as a replacement.
  • Removed Amp\Promise\rethrow(): Unhandled errors are now automatically thrown into the event loop, so there's no need for that function anymore.
  • Unhandled errors can be ignored using Future::ignore() if needed, but should usually be handled in some way.
  • Removed Amp\Promise\wrap(): Use Future::finally() instead.
  • Renamed Amp\getCurrentTime() to Amp\now() returning the time in seconds instead of milliseconds.
  • Changed Amp\delay() to accept the delay in seconds now instead of milliseconds.
  • Added Amp\weakClosure() to allow a class to hold a self-referencing Closure without creating a circular reference that prevents automatic garbage collection.
  • Added Amp\trapSignal() to await one or multiple signals.

Promise Combinators

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

  • 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

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.

Closable

Amp\Closable has been added as a new basic interface for closable resources such as streams or sockets.

Strict Types

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.

v3.0.0-beta.11
  • Removed circular dependency on amphp/phpunit-util (#408).
  • Added stack-trace of Future creation to UnhandledFutureError which is defined only when assertions are enabled (#405).
  • 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.
v3.0.0-beta.10

What's Changed

Full Changelog: https://github.com/amphp/amp/compare/v3.0.0-beta.9...v3.0.0-beta.10

v3.0.0-beta.9
  • Fixed circular reference in async() on exceptions (https://github.com/amphp/amp/issues/394)
  • Removed deprecated combinator functions:
    • Amp\Future\raceAmp\Future\awaitFirst
    • Amp\Future\anyAmp\Future\awaitAny
    • Amp\Future\someAmp\Future\awaitAnyN
    • Amp\Future\settleAmp\Future\awaitAll
    • Amp\Future\allAmp\Future\await
v3.0.0-beta.8
  • Fixed weakClosure() not preserving scope when using a Closure with scope limited to a parent class (#393)
  • Fixed regression in beta 9 where CompositeCancellation would return false from isRequested() and not throw from throwIfRequested() after cancellation was requested
v3.0.0-beta.7
  • Added SignalCancellation that triggers a cancellation when a particular signal is received by the process.
  • Fixed an issue in CombinedCancellation where subsequent cancellation of another Cancellation in the set could alter the exception used to cancel the token.
v3.0.0-beta.6
  • Added ForbidCloning and ForbidSerialization traits as a convenient way to forbid cloning and/or serialization in a class.
v3.0.0-beta.5
  • Added 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)
v2.6.2
  • Fixed a memory leak in CombinedCancellationToken (#384)
v3.0.0-beta.4

Note: This is a pre-release, there might be breaking changes in the final stable version.

  • Mark Future template parameter as covariant
  • Add compatibility with revolt/event-loop v0.2.x
  • Improve exception message of UnhandledFutureError
  • Cancel DeferredCancellation when destroyed (#382)
  • Rename combinators, introduce CompositeLengthException (#383)
    • raceawaitFirst
    • anyawaitAny
    • someawaitAnyN
    • settleawaitAll
    • allawait
    • The old names have been kept for a migration phase, but will be removed before the final v3 release.
v3.0.0-beta.3

Note: This is a pre-release, there might be breaking changes in the final stable version.

  • Add optional args to Amp\async (#379)
v3.0.0-beta.2

Note: This is a pre-release, there might be breaking changes in the final stable version.

  • Fixed revolt/event-loop dependency declaration to use released ^0.1 version.
v3.0.0-beta.1

Note: This is a pre-release, there might be breaking changes in the final stable version.

Event Loop

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.

Futures

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().
  • Unhandled errors are now automatically thrown into the event loop, so there's no need for Amp\Promise\rethrow() anymore.
  • Unhandled errors can be ignored using Future::ignore().

Cancellation

  • 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
v2.6.1
  • Fixed destructor issue in EventDriver (#358)
  • Fixed EventDriver feature configuration to work with different kinds of FDs, e.g. under certain conditions in docker containers (#360)
v2.6.0
  • Add Deferred::isResolved()
  • Implement except handling on Windows (#341)
  • Drop PHP 7.0 support
v2.5.2
  • Ignore only 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.
  • Improve type definition for combinators (any, first, some) (#334)
  • Removed internal `TimerQueueEntry
v2.5.1
  • Fixed issue where cancelling timer watchers in NativeDriver could result in timers being executed out of order (#332)
  • Fixed 100% CPU usage in NativeDriver when only signal watchers were enabled
v2.5.0
  • Add Amp\Iterator\discard() (#315)
  • Fix potential warning on shutdown in UvDriver
  • Fix repeat watchers in NativeDriver that are disabled and re-enabled during callback invocation (#325)
  • Fix timer intervals being counted from timer creation instead of last tick time (#319)
  • Loop::now() / Driver::now() is no longer cached in each tick
v2.4.4
  • Fixed Delayed::reference() / Delayed::unreference() after the promise resolved
  • Changed return type of Delayed::reference() / Delayed::unreference() to self to allow fluid API usage
  • Add generics for Amp\Promise\wait
  • Improved types for Amp\call / Amp\coroutine
v2.4.3
  • Improved types for Amp\call
  • Improved types for Deferred::resolve() (#307)
v2.4.2
  • Provide useful exception trace in TimeoutCancellationToken (#303)
  • Add parameter for custom timeout message (#299)
  • Add psalm annotations for improved static analysis
v2.4.1
  • Fixed undefined index warning when stream_select() fails but error_get_last() returns null.
v2.4.0
  • Added 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.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport