varion / transport
User-facing facade for the Varion Transport API
v0.1.0
2026-03-07 17:47 UTC
Requires
- php: ^8.1
- varion/transport-contracts: ^0.1
Requires (Dev)
- phpunit/phpunit: ^10.5
README
User-facing facade for the experimental Varion Transport API.
What this package is
varion/transport provides a small, stable entry point for application code. It does not implement network transport itself. Instead, it delegates to an injected driver that implements varion/transport-contracts.
Package roles in the architecture
varion/transport-contracts: shared interfaces onlyvarion/transport: facade layer used by applicationsvarion/driver-*: concrete implementations (for example,varion/driver-stream)
This keeps the API explicit and testable: your app depends on one facade, and you choose a compatible driver package separately.
Installation
composer require varion/transport
Install a compatible driver package as well, for example:
composer require varion/driver-stream
Usage (client)
<?php declare(strict_types=1); use Varion\Transport\Driver\Stream\StreamDriver; use Varion\Transport\Transport; $transport = new Transport(new StreamDriver()); $conn = $transport->connect('tcp://127.0.0.1:8080'); $conn->write("ping\n"); $response = $conn->read(1024); $conn->close();
Usage (server)
<?php declare(strict_types=1); use Varion\Transport\Driver\Stream\StreamDriver; use Varion\Transport\Transport; $transport = new Transport(new StreamDriver()); $listener = $transport->listen('tcp://127.0.0.1:8080'); while ($conn = $listener->accept()) { $data = $conn->read(1024); $conn->write("HTTP/1.0 200 OK\\r\\nContent-Length: 2\\r\\n\\r\\nOK"); $conn->close(); }
API surface
Transport::__construct(DriverInterface $driver)Transport::connect(string $uri, array $options = []): ConnectionInterfaceTransport::listen(string $uri, array $options = []): ListenerInterfaceTransport::driver(): DriverInterface
connect() and listen() validate that the URI is non-empty and then delegate to the injected driver.
Development
composer install vendor/bin/phpunit