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.
PageclassA 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
ProtocolclassHow 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 $componentpublic readonly array $propspublic readonly string $urlpublic 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(): arrayProtocol 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): boolA visit within the site: the page in JSON.
Protocol::answer()
public static function answer(Page $page, ?string $header, ?string $clientVersion, \Closure $shell): arrayThe 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): stringProtocol::root()
public static function root(Page $page, string $id = 'app'): stringThe root element holding the page, for the shell's body.