PHPackages                             amphp/quic - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. amphp/quic

ActiveLibrary

amphp/quic
==========

6811PHP

Since Jan 6Pushed 2y ago4 watchersCompare

[ Source](https://github.com/amphp/quic)[ Packagist](https://packagist.org/packages/amphp/quic)[ RSS](/packages/amphp-quic/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (1)

amphp/quic
==========

[](#amphpquic)

AMPHP is a collection of event-driven libraries for PHP designed with fibers and concurrency in mind. `amphp/quic` is a library for establishing quic connections. It provides a socket abstraction for clients and servers. It abstracts the really low levels of the [cloudflare/quiche](https://github.com/cloudflare/quiche) library.

[![MIT License](https://camo.githubusercontent.com/942e017bf0672002dd32a857c95d66f28c5900ab541838c6c664442516309c8a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e7376673f7374796c653d666c61742d737175617265)](https://github.com/amphp/quic/blob/master/LICENSE)

Installation
------------

[](#installation)

This package can be installed as a [Composer](https://getcomposer.org/) dependency.

```
composer require amphp/quic
```

Requirements
------------

[](#requirements)

`amphp/quic` implements the basic Server and Client interfaces of `amphp/socket`. It requires the FFI extension to be installed.

TLS
---

[](#tls)

Given that QUIC requires TLS, it is required to have a valid certificate on the server side. Also, one or more application layer protocol names (ALPN) MUST be specified.

*Note*: Fingerprinting is not supported and ignored. To use a self-signed certificate, disabling peer verification is required, or having a proper custom root CA.

Connecting to a Server
----------------------

[](#connecting-to-a-server)

The simplest way to connect is just a target and an ALPN protocol.

```
$quicConnection = \Amp\Quic\connect("example.com:1234", ["alpn protocol"]);
```

### Handling connections

[](#handling-connections)

Every QUIC connection is multiplexing streams. `QuicConnection` allows creating and accepting new streams.

Use `accept()` to await a new stream (`QuicSocket`), similarly to `Amp\Socket\ServerSocket`. Create new streams with `openStream()`. Also, datagrams can be sent and received on the connection with `sendDatagram()` and `receiveDatagram()`.

QUIC streams implement `Amp\Socket\Socket` for sending and receiving data.

Shutting down a connection via `close()` (or losing all references to it) immediately terminates all streams.

Server
------

[](#server)

`amphp/quic` allows listening for incoming QUIC connections over UDP. As with the client, it requires an ALPN protocol. Also a valid TLS certificate is required.

```
$tls = (new ServerTlsContext)
    ->withDefaultCertificate(new Certificate(__DIR__ . "/cert.pem", __DIR__ . "/key.pem"))
    ->withApplicationLayerProtocols(["test"]);

$quicServerSocket = \Amp\Quic\bind(["0.0.0.0:1234", "[::]:1234"], $tls);
```

*Note*: SNI based certificate distinction is not supported. There must be exactly one certificate provided via `ServerTlsContext::withDefaultCertificate()`.

### Accepting connections

[](#accepting-connections)

It's possible to `accept()` on a `QuicServerSocket`, but this will directly return a `QuicSocket`. This mode of operation is recommended, when connections do not have a specific meaning and streams are all what you are intersted in.

To actually get a `QuicConnection`, use `acceptConnection()`:

```
while ($quicConnection = $quicServerSocket->acceptConnection()) {
    async(function() use ($quicConnection) {
        // handle the connection, open and accept new streams, send and receive datagrams
    })
}
```

Configuration
-------------

[](#configuration)

While most configuration of `Amp\Socket\ConnectContext` and `Amp\Socket\BindContext` is understood and applied, there is also QUIC specific configuration exposed by `QuicConfig` and the respective child classes `QuicClientConfig` and `QuicServerConfig` which are both accepted by the `connect()` and `bind()` functions respectively.

Note that the QUIC interface generally accepts all sorts of communication, i.e. unidirectional streams, bidirectional streams and datagrams, as well as having an idle timeout for timely connection timeouts, with a ping being sent every so often to prevent timeouts on live connections. In particular QUIC servers may desire to tweak these settings.

Security
--------

[](#security)

If you discover any security related issues, please email [`me@kelunik.com`](mailto:me@kelunik.com) instead of using the issue tracker.

License
-------

[](#license)

The MIT License (MIT). Please see [`LICENSE`](./LICENSE) for more information.

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity21

Early-stage or recently created project

 Bus Factor1

Top contributor holds 65% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/f6db63ad594446f67d79532b75c69439fd0df779cc90868b43c187c02a4221ef?d=identicon)[bwoebi](/maintainers/bwoebi)

---

Top Contributors

[![bwoebi](https://avatars.githubusercontent.com/u/3154871?v=4)](https://github.com/bwoebi "bwoebi (26 commits)")[![trowski](https://avatars.githubusercontent.com/u/1628287?v=4)](https://github.com/trowski "trowski (14 commits)")

### Embed Badge

![Health badge](/badges/amphp-quic/health.svg)

```
[![Health](https://phpackages.com/badges/amphp-quic/health.svg)](https://phpackages.com/packages/amphp-quic)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
