NexusConfig is an immutable final class value object holding every setting required to build a client (with the API key stored outside public properties in a WeakMap and read via $config->apiKey() so it never leaks in var_dump or exception traces). Pass it to NexusClient::create.
Field reference
Service endpoint
WithbaseUrl empty, NexusConfig reads the endpoint from WESTYX_SERVICE_ENDPOINT (NexusConfig::SERVICE_ENDPOINT_ENV), and $config->baseUrl holds the resolved value. westyx dev run sets the variable for the script’s service, so together with a developer session an application started by it needs neither an endpoint nor a key:
- A
baseUrlyou pass always wins; the variable is read only when the argument is empty or blank. - The variable is trimmed, and a value empty after trimming counts as unset.
- It is validated like the argument -
https, orhttpon loopback only - and an error about its value namesWESTYX_SERVICE_ENDPOINTrather thanbaseUrl. - With neither set, the constructor throws
InvalidArgumentExceptionnaming both.
getenv(), from the process environment. The CLI server (php artisan serve, php -S), queue workers and console commands - what westyx dev run starts - all see it. PHP-FPM workers do not by default (clear_env = yes), so under FPM pass the endpoint as baseUrl or list the variable in the pool’s env[...] directives.
Validation
Every option is resolved and validated whenNexusConfig is constructed, and an invalid one is rejected naming the option, the value, and - for the reconnect schedule - the array index:
Coercing a bad value into a working one hides the mistake: it resurfaces days later as unexplained load or a stalled stream, with nothing pointing at the cause. An unusable value is rejected at construction, naming the option, the value and the array index, rather than being adjusted to something that works.
API key types
Where to keep the API key
Use environment variables - never hardcode the key in source:NEXUS_BASE_URL and NEXUS_API_KEY; the service provider reads them.
The SDK never logs the API key, a session token or a secret value. The startup line carries the key type and the names the first sync delivered:
Choosing the TTL
The TTL controls how long the in-memory cache is considered fresh before a background sync is triggered. With SSE enabled (connectStream()), changes propagate within milliseconds regardless of the TTL - the TTL only matters as a fallback when the stream is not running (FPM request handlers, for example).
In PHP-FPM, each request creates a fresh PHP process, so the cache is always empty at the start of a request and the TTL has no staleness effect across requests. The TTL is relevant only for long-running CLI daemons and queue workers.
Custom HTTP client
The factory accepts a PSR-18 client as its second argument, so the stack your application already configures - its timeouts, CA bundle, proxy, middleware and instrumentation - is what talks to Nexus:Do not set a timeout that is too short - the initial sync is blocking and must complete before
create returns. 10 seconds is a sensible minimum.WifConfig overview
When you pass aWifConfig to NexusConfig::$wif, the SDK exchanges the workload’s own credential for a Nexus session and sends it as Authorization: Bearer. An apiKey set alongside is used only when a refresh fails and the session has expired:
WifCredentialSource extension point, and token exchange details.