GitHub

Custom configuration

define() sends data to the browser as a module of its own. PHP decides the settings, your modules read them by name.
Controller.php
// with the page
BigPipe::page()->define('AppConfig', [
    'locale' => 'en',
    'request' => ['timeout' => 8000, 'retries' => 2],
]);

// or with any response, replacing the module
return (new AsyncResponse())
    ->define('AppConfig', $newConfig)
    ->call('tutorial/ConfigReader', 'show', [
        TransportMarker::element('config-output'),
    ])
    ->send();

// JavaScript
const { locale } = requireModule('AppConfig');
Try it

Choose a language.

A configuration that any response can change

The configuration is a module of the page. Each response defines it again, and the module reads the new values when it is called.