Skip to content

omnibridge/react API reference

Floor
Bridge
Version
1.x
Verified for real
Its README does not say
Licence
MIT
composer require omnibridge/react:1.x-dev

Read from the package's own PHP files at the commit 45e3f6916122: its namespaces, classes, interfaces and enums, their public constants, properties and methods with their PHPDoc, and the options its factories take. Nothing of it is run.

Omnibridge\React

  • Page class

    A page as React renders it: the name of its component, its props (plain data), its address and the version of the front end that renders it. The same from any framework: Symfony and Laravel give it alike.

    2 methods · 4 properties

  • Protocol class

    How a page travels. The first visit is an HTML shell holding the page (data-page on the root element), whose script renders it; a visit within the site asks with the header X-Omnibridge and gets the page in JSON, its version in X-Omnibridge-Version; a front end of another version than the server's reloads the address whole (409 and X-Omnibridge-Location).

    4 methods · 3 constants

Omnibridge\React

Page class

final class Page implements JsonSerializable Page.php:10

A page as React renders it: the name of its component, its props (plain data), its address and the version of the front end that renders it. The same from any framework: Symfony and Laravel give it alike.

public readonly string $component
public readonly array $props
public readonly string $url
public readonly ?string $version

Page::__construct()

public function __construct(public readonly string $component, public readonly array $props, public readonly string $url, public readonly ?string $version = null)

Page::jsonSerialize()

public function jsonSerialize(): array

Protocol class

final class Protocol Protocol.php:13

How a page travels. The first visit is an HTML shell holding the page (data-page on the root element), whose script renders it; a visit within the site asks with the header X-Omnibridge and gets the page in JSON, its version in X-Omnibridge-Version; a front end of another version than the server's reloads the address whole (409 and X-Omnibridge-Location).

Framework-free: an application turns these answers into its responses.

const HEADER = 'X-Omnibridge'
const VERSION = 'X-Omnibridge-Version'
const LOCATION = 'X-Omnibridge-Location'

Protocol::wantsJson()

public static function wantsJson(?string $header): bool

A visit within the site: the page in JSON.

Protocol::answer()

public static function answer(Page $page, ?string $header, ?string $clientVersion, \Closure $shell): array

The answer to a request, as status, headers and body; the shell is the application's (its head, its scripts) around the root element given.

Protocol::json()

public static function json(Page $page): string

Protocol::root()

public static function root(Page $page, string $id = 'app'): string

The root element holding the page, for the shell's body.