Skip to main content
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

With baseUrl 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 baseUrl you 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, or http on loopback only - and an error about its value names WESTYX_SERVICE_ENDPOINT rather than baseUrl.
  • With neither set, the constructor throws InvalidArgumentException naming both.
The variable is read with 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 when NexusConfig 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

Calling getSecret(...) or getSecretFilePath(...) with a public key throws NexusPublicKeyException before any network call is made.

Where to keep the API key

Use environment variables - never hardcode the key in source:
In Laravel, set 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:
Any PSR-18 implementation works - Guzzle above, Symfony HttpClient, or your own. Pass nothing and the SDK discovers whichever one the project has installed. See HTTP client.
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 a WifConfig 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:
See Workload identity for the full provider table, the WifCredentialSource extension point, and token exchange details.