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 2.2.9
What’s Changed
- Fixed a race condition if outstanding accept calls were pending when closing
SocketIpcHub
. - Removed use of error-suppression operator to avoid warnings from mis-configured error handlers (#200).
Full Changelog: https://github.com/amphp/parallel/compare/v2.2.8…v2.2.9
- Fixed a race condition if outstanding accept calls were pending when closing
-
amphp/parser 1.1.1
What’s Changed
- Make implicit nullable types explicit by @nicolas-grekas in https://github.com/amphp/parser/pull/6
New Contributors
- @nicolas-grekas made their first contribution in https://github.com/amphp/parser/pull/6
Full Changelog: https://github.com/amphp/parser/compare/v1.1.0…v1.1.1
-
amphp/hpack 3.2.1
What’s Changed
- Make implicit nullable types explicit by @nicolas-grekas in https://github.com/amphp/hpack/pull/16
Full Changelog: https://github.com/amphp/hpack/compare/v3.2.0…v3.2.1
-
amphp/socket 2.3.0
- Added
Socks5SocketConnector
to connect to hosts via SOCKS5 proxies. A similar implementation was previously present inamphp/http-tunnel
.
- Added
-
amphp/rpc 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/sync 2.2.0
What’s Changed
- Add PriorityQueue by @trowski in https://github.com/amphp/sync/pull/27
Full Changelog: https://github.com/amphp/sync/compare/v2.1.0…v2.2.0
-
amphp/mysql 3.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
.- Classes and interfaces now are prefixed with
Mysql
to avoid collisions with similar names from other libraries. - Marked most classes as internal, leaving only interfaces and concrete implementations required to use the API or create a custom connector.
MysqlTransaction
now extendsMysqlLink
instead ofMysqlExecutor
to support nested transactions.MysqlDataType
is now an enum of MySQL data type codes and methods to decode data based on type.- Result set field data is now available from
MysqlResult::getColumnDefinitions()
which returns an array ofMysqlColumnDefinition
objects corresponding to the result set rows. - The second param of
MysqlStatement::bind()
now requires a string. Binding only makes sense with long strings anyway. MysqlConnection
is now an interface extendingSqlConnection
, withSocketMysqlConnection
being the implementation.- Removed
MysqlConnector
since the interface was replaced by template types onSqlConnector
, i.e.SqlConnector<MysqlConfig, MysqlConnection>
- Classes and interfaces now are prefixed with
-
amphp/postgres 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
.- Non-extension-specific classes and interfaces now are prefixed with
Postgres
to avoid collisions with similar names from other libraries. - Result sets now implement
Traversable
, allowing them to be used withforeach
to iterate over result rows. - Marked most classes as internal, leaving only interfaces and concrete implementations required to use the API or create a custom connector.
PostgresTransaction
now extendsPostgresLink
instead ofPostgresExecutor
to support nested transactions.- Removed
TimeoutConnector
in favor ofDefaultPostgresConnector
which has aCancellation
parameter onconnect()
which may be used with anAmp\TimeoutCancellation
. - Removed
PostgresConnector
since the interface was replaced by template types onSqlConnector
, i.e.SqlConnector<PostgresConfig, PostgresConnection>
- Added support for
BYTEA
fields. (#57) - Added the
PostgresConnection
interface extendingPostgresLink
. - Removed the
Receiver
interface. These methods are now a part ofPostgresConnection
. - Removed the
Quoter
Interface. These methods are now a part ofPostgresExecutor
.
- Non-extension-specific classes and interfaces now are prefixed with
-
amphp/sql-common 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
.- Added template types to interfaces for better type expression on implementations and extensions.
- All classes now start with
Sql
as a prefix to avoid name collisions with other libraries. - Renamed
ConnectionPool
toSqlCommonConnectionPool
. - Added
SqlNestedableTransactionExecutor
andSqlNestedTransaction
to support nested transactions. - Added
SqlCommandResult
andSqlConnectionTransaction
. - Renamed
PooledResultSet
toSqlPooledResult
.
-
amphp/sql 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
.- Added template types to interfaces for better type expression on implementations and extensions.
- All classes now start with
Sql
as a prefix to avoid name collisions with other libraries. - Combined
ResultSet
andCommandResult
into a single interface,SqlResult
. SqlTransaction
now extendsSqlLink
instead ofSqlExecutor
to support nested transactions.- Added
onCommit()
andonRollback()
methods toSqlTransaction
. These methods attach callbacks after the transaction is either committed or rolled back, respectively. - Removed the methods
createSavepoint()
,rollbackTo()
, andreleaseSavepont()
fromSqlTransaction
. Use nested transactions throughSqlTransaction::beginTransaction()
instead. SqlPool
now extendsSqlConnection
instead ofSqlLink
.SqlPool::extractConnection()
returns an instance ofSqlConnection
instead ofSqlLink
.- Added
SqlResult::fetchRow()
, which will return a single row (associative array) from the result set on each call until no further rows remain in the result. SqlTransientResource
and now extendsAmp\Closable
.- Added
SqlTransactionIsolation
and an enum-based implementation,SqlTransactionIsolationLevel
. - Renamed
ConnectionConfig
toSqlConfig
. - Renamed
FailureException
toSqlException
.
-
amphp/pipeline 1.2.0
What’s Changed
- Added
Pipeline::buffer()
, which provides control of the number of values buffered by the pipeline before back-pressure is applied to the data source by @trowski in https://github.com/amphp/pipeline/pull/21
Full Changelog: https://github.com/amphp/pipeline/compare/v1.1.0…v1.2.0
- Added
-
amphp/byte-stream 2.1.1
What’s Changed
- Fixed cancellation not being forwarded to
split()
insplitLines()
.
Full Changelog: https://github.com/amphp/byte-stream/compare/v2.1.0…v2.1.1
- Fixed cancellation not being forwarded to
-
amphp/process 2.0.2
What’s Changed
- Changed waiting for children during shutdown to be synchronous to ensure all children are properly cleaned up. This should avoid zombie processes left when running within an SAPI such as PHP-FPM.
- Fixed
UnhandledFutureError
being thrown to event loop if reading the process exit code fails.
Full Changelog: https://github.com/amphp/process/compare/v2.0.1…v2.0.2
-
amphp/dns v2.1.1
What’s Changed
- Corrected error message unit scale (ms -> seconds) by @Bilge in https://github.com/amphp/dns/pull/113
- Fixed Windows nameserver detection by only enumerating real NICs by @Bilge in https://github.com/amphp/dns/pull/114
New Contributors
- @Bilge made their first contribution in https://github.com/amphp/dns/pull/113
Full Changelog: https://github.com/amphp/dns/compare/v2.1.0…v2.1.1
-
amphp/windows-registry 1.0.1
What’s Changed
- Removed nullability from return type of
WindowsRegistry::read()
, the method throws if the key is not found.
Full Changelog: https://github.com/amphp/windows-registry/compare/v1.0.0…v1.0.1
- Removed nullability from return type of
-
amphp/websocket-server 4.0.0
The
4.0.0
release fixes compression support with a couple small compatibility breaks from3.x
.Users of
2.x
should upgrade directly to4.0.0
.Users of
3.x
can upgrade directly to4.0.0
if compression is not being used. If a customWebsocketAcceptor
was created to support compression, this custom implementation may be dropped, instead passing an instance ofWebsocketCompressionContextFactory
to eachWebsocket
request handler.Backward Compatibility Breaks
- The
WebsocketCompressionContextFactory
constructor parameter ofRfc6455ClientFactory
has been removed and is instead a constructor parameter of theWebsocket
class. - A nullable
WebsocketCompressionContext
parameter was added toWebsocketClientFactory::createClient()
.
- The
-
amphp/websocket 2.0.3
What’s Changed
WebsocketException
now extendsAmp\ByteStream\StreamException
to avoid violating theReadableStream
interface by throwing a non-StreamException
from a stream method.
Full Changelog: https://github.com/amphp/websocket/compare/v2.0.2…v2.0.3
-
amphp/http-server 3.3.0
What’s Changed
RequestBody
now implementsStringable
so the entire request body can be buffered by simply casting the object to a string (note the request body length limits still apply).- Fixed the HTTP/2 initial window size being potentially larger than the client would accept.
- Fixed incrementing the HTTP/2 window size if the body size limit is very large.
ClientException
now extendsAmp\ByteStream\StreamException
to avoid violating theReadableStream
interface by throwing a non-StreamException
from a stream method.
New Contributors
- @cwhite92 made their first contribution in https://github.com/amphp/http-server/pull/353
- @foremtehan made their first contribution in https://github.com/amphp/http-server/pull/356
Full Changelog: https://github.com/amphp/http-server/compare/v3.2.0…v3.3.0
-
amphp/websocket-client 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
.This release is compatible with
amphp/http-client@^5
andamphp/websocket@^2
. See the release notes of these libraries for further change notes.Similar to
v1
, a Websocket connection is created usingAmp\Websocket\Client\connect()
or using an instance ofWebsocketConnector
, callingWebsocketConnector::connect()
. The returnedWebsocketConnection
then is used to send and receive WebSocket messages.- Renamed most classes and interfaces to add
Websocket
as a prefix to avoid name collisions with similarly named classes in other packages which are frequently used together. For example,Connection
is nowWebsocketConnection
. - Advanced handshake and connection parameters may be specified using a
Rfc6455ConnectionFactory
instance provided when constructing aRfc6455Connector
. - A global
WebsocketConnector
instance may be accessed and set viaAmp\Websocket\Client\websocketConnector()
.
- Renamed most classes and interfaces to add
-
amphp/file 3.0.2
What’s Changed
- Fixed detecting if a file is writing from the file mode when
r+
(or similar) is used as the mode. (#77) - Fixed assertion failing during shutdown destruction of
ParallelFilesystemDriver
. (#81)
Full Changelog: https://github.com/amphp/file/compare/v3.0.1…v3.0.2
- Fixed detecting if a file is writing from the file mode when
-
amphp/http-client 5.0.1
What’s Changed
- Fail streams only with StreamException by @trowski in https://github.com/amphp/http-client/pull/354. Response body streams will now only throw
StreamException
orCancelledException
as specified by theReadableStream
interface.
Full Changelog: https://github.com/amphp/http-client/compare/v5.0.0…v5.0.1
- Fail streams only with StreamException by @trowski in https://github.com/amphp/http-client/pull/354. Response body streams will now only throw
-
amphp/php-cs-fixer-config 2.0.1
- Removed deprecated rules (#7)
Full Changelog: https://github.com/amphp/php-cs-fixer-config/compare/v2.0.0…v2.0.1
-
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/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
InMemoryCookieJar
toLocalCookieJar
- Renamed
-
amphp/http-server-form-parser 2.0.0
This release is compatible with
amphp/http-server@^3
.- Renamed
BufferingParser
andStreamingParser
toFormParser
andStreamingFormParser
, respectively. - Removed the
parseForm
function in favor of theForm::fromRequest()
static method. - Removed
ParsingMiddleware
. UseForm::fromRequest()
instead. - Removed
ParseException
. Form parsing errors will throw anHttpErrorException
fromamphp/http-server
instead, which do not need to be caught (the server will automatically return an error response).
- Renamed
-
amphp/http 2.1.0
- Updated
league/uri-components
requirements to^2.4.2 | ^7.1
as 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
, andDriver
toSessionStorage
,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
SessionTrainer
for 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
RedisParcel
in theSync
sub-namespace implementing theParcel
interface fromamphp/sync
- Added
RedisConnector
interface to decouple connecting and init commands such asAUTH
andSELECT
- Reorganized class names / namespaces for better overview
Redis
moved toRedisClient
Subscriber
/Subscription
moved toRedisSubscriber
/RedisSubscription
Cache
moved toRedisCache
Mutex
sub-namespace has been changed toSync
. All classes within now have a prefix of Redis, e.g.,Mutex
→RedisMutex
,MutexOptions
→RedisMutexOptions
Config
moved toRedisConfig
RespSocket
moved toAmp\Redis\Connection\RedisConnection
and is an interface nowRespParser
moved toAmp\Redis\Protocol\RespParser
QueryExecutor
moved toAmp\Redis\Connection\RedisLink
RemoteExecutor
moved toAmp\Redis\Connection\ReconnectingRedisLink
RedisHyperLogLog
moved toAmp\Redis\Command\RedisHyperLogLog
RedisList
moved toAmp\Redis\Command\RedisList
RedisMap
moved toAmp\Redis\Command\RedisMap
RedisSet
moved toAmp\Redis\Command\RedisSet
RedisSortedSet
moved toAmp\Redis\Command\RedisSortedSet
SortOptions
moved toAmp\Redis\Command\Option\SortOptions
SetOptions
moved toAmp\Redis\Command\Option\SetOptions
SocketException
moved toAmp\Redis\Connection/RedisConnectionException
ParserException
moved toAmp\Redis\Protocol\ProtocolException
QueryException
moved toAmp\Redis\Protocol\QueryException
RedisSubscription
is now a simple PHP iterator now thatAmp\Iterator
is no longer necessary with fibers.
- Added
-
amphp/http-server-static-content 2.0.0
This release is compatible with
amphp/http-server@^3
.DocumentRoot
now requires an instance ofHttpServer
andErrorHandler
to 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
StaticResource
to serve a single static file
-
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
Router
constructor - Starting the server with an empty
Router
is 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/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
ArrayCache
toLocalCache
, swapping the constructor argument order - Modified
LocalCache
to implementIteratorAggregate
andCountable
, acting as an LRU cache now (#20) - Support arbitrary values in
LocalCache
,NullCache
, andPrefixCache
- Changed
Cache
to support arbitrary values - Introduced separate
StringCache
interface for caching only strings - Added
StringCacheAdapter
to use anyCache
in place of aStringCache
- Removed
FileCache
(will be available inamphp/file
instead)
- Renamed
-
amphp/phpunit-util 3.0.0
This package has been redesigned for compatibility with AMPHP v3 and fibers.
AsyncTestCase
serves 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\EventLoop
is quite similar to Amp’s previousAmp\Loop
. A very important difference is usingfloat $seconds
instead ofint $milliseconds
for timers though!Promises
Future
is a replacement for the previousPromise
. There’s no need for callbacks oryield
anymore! Itsawait()
method is based on fibers and replaces generator based coroutines /Amp\Promise\wait()
.- Renamed
Amp\Deferred
toAmp\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 allyield
keywords, 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
CancellationToken
has been renamed toCancellation
.CancellationTokenSource
has been renamed toDeferredCancellation
.NullCancellationToken
has been renamed toNullCancellation
.TimeoutCancellationToken
has been renamed toTimeoutCancellation
.CombinedCancellationToken
has been renamed toCompositeCancellation
.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 newamphp/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. - Renamed
-
amphp/cluster 1.0.1
Update to use
amphp/file
v2.x
. -
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\Factory
is 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=1
as environment variable or constant to disable this protection.
-
amphp/react-stream-adapter 0.1.0
Initial release.