varion/transport

User-facing facade for the Varion Transport API

Maintainers

Package info

github.com/varionlabs/transport

pkg:composer/varion/transport

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.1.0 2026-03-07 17:47 UTC

This package is auto-updated.

Last update: 2026-03-07 17:49:36 UTC


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 only
  • varion/transport: facade layer used by applications
  • varion/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 = []): ConnectionInterface
  • Transport::listen(string $uri, array $options = []): ListenerInterface
  • Transport::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