Build fast, concurrent applications with PHP
Benefit from concurrency by replacing your blocking I/O with non-blocking I/O,
or designing your system with non-blocking I/O from the ground up.
We shipped fibers in PHP 8.1 to extend its capabilities for concurrent applications.
The PHP standard library has already provided everything else we needed for years now, but it only ships the low-level building blocks. AMPHP provides higher-level libraries using non-blocking I/O under the hood. Fibers allow these libraries to just work, no matter whether they're used in concurrent or traditional contexts.
Latest Releases
-
amphp/parallel-functions 2.0.0
Stable release compatible with AMPHP v3 and fibers! 🎉
As with other libraries compatible with AMPHP v3, most cases of parameters or returns of
Promise<ResolutionType>have been replaced withResolutionType. -
amphp/parallel 2.2.3
- Fixed accepting a socket with
SocketIpcHub::accept()after cancelling a prior accept operation.
Full Changelog: https://github.com/amphp/parallel/compare/v2.2.2…v2.2.3
- Fixed accepting a socket with
-
amphp/byte-stream 2.1.0
What’s Changed
Payloadnow implementsStringable- Add cancelation support for
splitby @xtrime-ru in https://github.com/amphp/byte-stream/pull/108
New Contributors
- @xtrime-ru made their first contribution in https://github.com/amphp/byte-stream/pull/108
Full Changelog: https://github.com/amphp/byte-stream/compare/v2.0.2…v2.1.0
-
amphp/dns 2.1.0
- Fixed name resolution when NDots > 1
- Added
Cancellationarguments toAmp\Dns\query()andAmp\Dns\resolve().
Full Changelog: https://github.com/amphp/dns/compare/v2.0.1…v2.1.0
-
amphp/websocket-server 3.0.1
Disables support for WebSocket compression.
An unfortunate last-minute API design decision in the 3.x branch broke support for WebSocket compression. While it would be possible to fix this by introducing some new interfaces and classes and deprecating the old interfaces in the 3.x branch, we decided the more elegant solution would be to release a 4.x with a minor BC break. Further details will be provided in the 4.x releases.
This release marks the
WebsocketCompressionContextFactoryconstructor parameter ofRfc6455ClientFactoryas deprecated and unused. Passing a compression context factory will not enable compression on the server. -
amphp/websocket 2.0.2
- Fixed #11:
Rfc7692Compression::fromClientHeader()now accepts headers includingclient_max_window_bitswithout a value.
- Fixed #11:
-
amphp/http-client-cookies 2.0.0
Stable release compatible with AMPHP v3 and fibers! 🎉
As with other libraries compatible with AMPHP v3, most cases of parameters or returns of
Promise<ResolutionType>have been replaced withResolutionType.- Renamed
InMemoryCookieJartoLocalCookieJar
- Renamed
-
amphp/http-client 5.0.0
Stable release compatible with AMPHP v3 and fibers! 🎉
As with other libraries compatible with AMPHP v3, most cases of parameters or returns of
Promise<ResolutionType>have been replaced withResolutionType.Requestinstances are mutable now and can no longer be reused.- Removed cloning of request attributes – You can use any value in attributes now.
Requestnow extendsHttpRequestfromamphp/http, gaining methods to get and set query parameters on the request instead of needing to manipulate the URI object directly.- Renamed header methods using the term “raw” to use “pairs” instead, e.g.,
getRawHeaders()→getHeaderPairs(),parseRawHeaders()→parseHeaderPairs() - Changed timeout unit from milliseconds to seconds (like timers in the event loop)
- Removed
UnprocessedRequestException, useRequest::isUnprocessed()instead. - The
EventListenerinterface has been reworked and event listeners can be registered withHttpClientBuilder::listen()now to automatically apply to each request instead of only being registered on specific requests. - Replaced
FormBodywith newFormAPI- Repeated form fields are no longer sent in PHP specific encoding, i.e.
appids=30&appids=20instead ofappids%5B0%5D=30&appids%5B1%5D=20(#340) If you need the previous names, add[]to the name of your field.
- Repeated form fields are no longer sent in PHP specific encoding, i.e.
- Replaced
RequestBodywith newHttpContentAPI- Added
BufferedContent - Added
StreamedContent - Removed
Body\FileBody - Removed
Body\FormBody - Removed
Body\JsonBody - Removed
Body\StreamBody - Removed
Body\StringBody
- Added
There are no changes compared to 5.0.0 Beta 17.
-
amphp/hpack 3.2.0
- Improved detection of
libnghttp2, i.e.libnghttp2.so.14and looking in the Homebrew path
Full Changelog: https://github.com/amphp/hpack/compare/v3.1.7…v3.2.0
- Improved detection of
-
amphp/http-server-form-parser 2.0.0
This release is compatible with
amphp/http-server@^3.- Renamed
BufferingParserandStreamingParsertoFormParserandStreamingFormParser, respectively. - Removed the
parseFormfunction in favor of theForm::fromRequest()static method. - Removed
ParsingMiddleware. UseForm::fromRequest()instead. - Removed
ParseException. Form parsing errors will throw anHttpErrorExceptionfromamphp/http-serverinstead, which do not need to be caught (the server will automatically return an error response).
- Renamed
-
amphp/http-server 3.2.0
- Allowed
league/[email protected]andpsr/message@v2 - Added previous param to
HttpErrorExceptionconstructor
Full Changelog: https://github.com/amphp/http-server/compare/v3.1.0…v3.2.0
- Allowed
-
amphp/http 2.1.0
- Updated
league/uri-componentsrequirements to^2.4.2 | ^7.1as part of fixing #24 and allowpsr/message@v2 - Changed request query string encoding to use RFC3986 rules to as part of fixing #24
Full Changelog: https://github.com/amphp/http/compare/v2.0.0…v2.1.0
- Updated
-
amphp/http-server-session 3.0.0
This release is compatible with
amphp/http-server@^3.- Renamed
Storage,InMemoryStorage,RedisStorage,DefaultIdGenerator, andDrivertoSessionStorage,LocalSessionStorage,RedisSessionStorage,Base64UrlSessionIdGenerator, andSessionFactory, respectively - Renamed methods on
Session:open()tolock(),save()tocommit() - Added
Session::rollback()to undo local changes and re-read the session data from storage - Added
SessionTrainerfor examining session changes unit testing
- Renamed
-
amphp/redis 2.0.0
Initial release compatible with AMPHP v3. As with other libraries compatible with AMPHP v3, most cases of parameters or returns of
Promise<ResolutionType>have been replaced withResolutionType.- Added
RedisParcelin theSyncsub-namespace implementing theParcelinterface fromamphp/sync - Added
RedisConnectorinterface to decouple connecting and init commands such asAUTHandSELECT - Reorganized class names / namespaces for better overview
Redismoved toRedisClientSubscriber/Subscriptionmoved toRedisSubscriber/RedisSubscriptionCachemoved toRedisCacheMutexsub-namespace has been changed toSync. All classes within now have a prefix of Redis, e.g.,Mutex→RedisMutex,MutexOptions→RedisMutexOptionsConfigmoved toRedisConfigRespSocketmoved toAmp\Redis\Connection\RedisConnectionand is an interface nowRespParsermoved toAmp\Redis\Protocol\RespParserQueryExecutormoved toAmp\Redis\Connection\RedisLinkRemoteExecutormoved toAmp\Redis\Connection\ReconnectingRedisLinkRedisHyperLogLogmoved toAmp\Redis\Command\RedisHyperLogLogRedisListmoved toAmp\Redis\Command\RedisListRedisMapmoved toAmp\Redis\Command\RedisMapRedisSetmoved toAmp\Redis\Command\RedisSetRedisSortedSetmoved toAmp\Redis\Command\RedisSortedSetSortOptionsmoved toAmp\Redis\Command\Option\SortOptionsSetOptionsmoved toAmp\Redis\Command\Option\SetOptionsSocketExceptionmoved toAmp\Redis\Connection/RedisConnectionExceptionParserExceptionmoved toAmp\Redis\Protocol\ProtocolExceptionQueryExceptionmoved toAmp\Redis\Protocol\QueryException
RedisSubscriptionis now a simple PHP iterator now thatAmp\Iteratoris no longer necessary with fibers.
- Added
-
amphp/http-server-static-content 2.0.0
This release is compatible with
amphp/http-server@^3.DocumentRootnow requires an instance ofHttpServerandErrorHandlerto construct- Removed
DocumentRoot::onStart()andDocumentRoot::onStop(), as it’s now internally registered - Removed support for
ServerObserver, as it’s been removed fromamphp/http-server - Added
StaticResourceto serve a single static file
-
amphp/socket 2.2.0
What’s Changed
- Add support for
league/uri7.x - Undefined variable
$socketin example by @61-6c-69 in https://github.com/amphp/socket/pull/106
New Contributors
- @61-6c-69 made their first contribution in https://github.com/amphp/socket/pull/106
Full Changelog: https://github.com/amphp/socket/compare/v2.1.0…v2.2.0
- Add support for
-
amphp/sync 2.1.0
What’s Changed
- Added re-entry support to
synchronized()by @kelunik in https://github.com/amphp/sync/pull/26 - Fixed error handling in
SharedMemoryParcel - Fixed a typo by @thgs in https://github.com/amphp/sync/pull/25
New Contributors
- @thgs made their first contribution in https://github.com/amphp/sync/pull/25
Full Changelog: https://github.com/amphp/sync/compare/v2.0.0…v2.1.0
- Added re-entry support to
-
amphp/http-server-router 2.0.0
This release is compatible with
amphp/http-server@^3.- A PSR-3 logger is now required in the
Routerconstructor - Starting the server with an empty
Routeris now allowed and only logs a notice instead of throwing an exception - Middleware can be added via
addMiddleware()instead ofstack() - Removed support for adding middleware directly via
addRoute(), usestackMiddleware()instead if you need this - Removed
Router::onStart(), as it’s now internally registered - Removed support for
ServerObserver, as it’s been removed fromamphp/http-server
- A PSR-3 logger is now required in the
-
amphp/log 2.0.0
- Increased minimum PHP version to 8.1
- Make use of fibers with Amp v3 and Revolt
- Added support for Monolog v3.x
This release does not contain any changes in comparison to
v2.0.0-beta.2. -
amphp/process 2.0.1
- Fixed error handling if the started process fails immediately.
Full Changelog: https://github.com/amphp/process/compare/v2.0.0…v2.0.1
-
amphp/file 3.0.1
What’s Changed
- Fix
touch()on non-existent files in ext-uv and ext-eio by @kelunik (#73) - Fix
write()truncation with ext-uv and ext-eio by @danog in (#76)
Full Changelog: https://github.com/amphp/file/compare/v3.0.0…v3.0.1
- Fix
-
amphp/windows-registry 1.0.0
Stable release compatible with AMPHP v3 and fibers! 🎉
As with other libraries compatible with AMPHP v3, most cases of parameters or returns of
Promise<ResolutionType>have been replaced withResolutionType.WindowsRegistryoffers the methods as static methods now instead of instance methods.
-
amphp/cache 2.0.0
Stable release compatible with AMPHP v3 and fibers! 🎉
As with other libraries compatible with AMPHP v3, most cases of parameters or returns of
Promise<ResolutionType>have been replaced withResolutionType.- Renamed
ArrayCachetoLocalCache, swapping the constructor argument order - Modified
LocalCacheto implementIteratorAggregateandCountable, acting as an LRU cache now (#20) - Support arbitrary values in
LocalCache,NullCache, andPrefixCache - Changed
Cacheto support arbitrary values - Introduced separate
StringCacheinterface for caching only strings - Added
StringCacheAdapterto use anyCachein place of aStringCache - Removed
FileCache(will be available inamphp/fileinstead)
- Renamed
-
amphp/postgres 1.4.5
- Fixed cancelling an active query if a connection is closed when using
ext-pgsql(#54)
- Fixed cancelling an active query if a connection is closed when using
-
amphp/sql-common 1.1.4
- Fixed potential double deferred resolve when a connection pool is full.
-
amphp/parser 1.1.0
- PHP 7.4 now required
- Improved performance of the parser when requesting small chunks of data and when yielding an integer length delimiter
-
amphp/pipeline 1.0.0
Initial stable release 🎉
Changes from 1.0.0 Beta 7
- Marked
ConcurrentArrayIterator,ConcurrentChainedIterator, andConcurrentIterableIteratoras@internal. Instead of these classes, usePipeline::fromIterable()orPipeline::concat() Pipeline::concat()now accepts an array of anyiterable, not only otherPipelineobjects
- Marked
-
amphp/sql 1.0.2
- Fix a deprecation notice on PHP 8.1 if a configuration key does not have a value.
-
amphp/phpunit-util 3.0.0
This package has been redesigned for compatibility with AMPHP v3 and fibers.
AsyncTestCaseserves a similar purpose as before, providing helper methods for unit testing within an async context. Each test case is run within a unique fiber to allow suspending during the test run.AsyncTestCase::setUpAsync()andtearDownAsync()have been removed. UseAsyncTestCase::setUp()andtearDown()instead, as both of these methods are now able to execute async using fibers.AsyncTestCase::createCallback()now returns aClosure. Additionally, an optional parameter for expected arguments upon invocation have been added (usesInvocationMocker::with(...)to set expected arguments).
-
amphp/amp 3.0.0
Event Loop
Amp no longer ships its own event loop. It’s now based on Revolt.
Revolt\EventLoopis quite similar to Amp’s previousAmp\Loop. A very important difference is usingfloat $secondsinstead ofint $millisecondsfor timers though!Promises
Futureis a replacement for the previousPromise. There’s no need for callbacks oryieldanymore! Itsawait()method is based on fibers and replaces generator based coroutines /Amp\Promise\wait().- Renamed
Amp\DeferredtoAmp\DeferredFuture. - Removed
Amp\Promise\wait(): UseAmp\Future::await()instead, which can be called in any (nested) context unlike before. - Removed
Amp\call(): Remove the passed closure boilerplate and allyieldkeywords, interruption is handled via fibers now instead of generator coroutines. - Removed
Amp\asyncCall(): Replace invocations withAmp\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 optionalCancellation, 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(): UseFuture::finally()instead. - Renamed
Amp\getCurrentTime()toAmp\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 toAmp\Future\awaitFirst()Amp\Promise\first()has been renamed toAmp\Future\awaitAny()Amp\Promise\some()has been renamed toAmp\Future\awaitAnyN()Amp\Promise\any()has been renamed toAmp\Future\awaitAll()Amp\Promise\all()has been renamed toAmp\Future\await()
CancellationToken
CancellationTokenhas been renamed toCancellation.CancellationTokenSourcehas been renamed toDeferredCancellation.NullCancellationTokenhas been renamed toNullCancellation.TimeoutCancellationTokenhas been renamed toTimeoutCancellation.CombinedCancellationTokenhas been renamed toCompositeCancellation.SignalCancellationhas been added.
Iterators
Iterators have been removed from
amphp/ampas 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 newamphp/pipelinelibrary now.Closable
Amp\Closablehas 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. - Renamed
-
amphp/php-cs-fixer-config 2.0.0
- Common code style for all packages based on Amp v3.
- Now includes
strict_typesand several other minor updates.
-
amphp/websocket-client 1.0.1
- Ignore
/docsin.gitattributesto avoid broken symlink (#38)
Full Changelog: https://github.com/amphp/websocket-client/compare/v1.0.0…v1.0.1
- Ignore
-
amphp/rpc 1.0.0
Initial release.
-
amphp/cluster 1.0.1
Update to use
amphp/filev2.x. -
amphp/mysql 2.1.2
- Fixed a bug when decoding a JSON field (#113)
-
amphp/beanstalk 0.3.2
- Added support for Symfony YAML library v4 and v5. (#34)
-
amphp/serialization 1.0.0
Initial release.
-
amphp/http-tunnel 1.0.0
Initial release.
-
amphp/http-client-cache 1.0.0
Initial release.
-
amphp/react-adapter 2.1.0
React\EventLoop\Factoryis now automatically replaced with another implementation that throws on each usage to prevent two loops existing concurrently by accident. SetAMP_REACT_ADAPTER_DISABLE_FACTORY_OVERRIDE=1as environment variable or constant to disable this protection.
-
amphp/react-stream-adapter 0.1.0
Initial release.