/PHP-Quiche

A Quiche-based QUIC implementation for PHP using FFI

Primary LanguagePHPBSD 2-Clause "Simplified" LicenseBSD-2-Clause

PHP-Quiche

A Quiche-based QUIC implementation for PHP

Installation

composer require nethergamesmc/quiche

Requires FFI to be enabled & the quiche library to be installed.

Usage

Client

<?php
$clientSocket = new QuicheClientSocket(
    new SocketAddress("127.0.0.1", 19132),
    function(QuicheConnection $connection, QuicheStream $stream) : void{
    // gets called when a new stream is opened
    }
);
$clientConfig = $clientSocket->getConfig();
$clientConfig->enableBidirectionalStreams();

$clientSocket->connect();

while(true){
    $clientSocket->tick();
}

Server

<?php
$serverSocket = new QuicheServerSocket(
    [new SocketAddress("127.0.0.1", 19132)],
    function(QuicheConnection $connection, ?QuicheStream $stream) : void{
    // gets called when a new connection is established or a new stream is opened
    }
);
$serverConfig = $serverSocket->getConfig();
$serverConfig->loadPrivKeyFromFile($pathToKey);
$serverConfig->loadCertChainFromFile($pathToCert);
$serverConfig->enableBidirectionalStreams();

while(true){
    $serverSocket->tick();
}