NexusClient
NexusClient in the PHP SDK.
// access
$nexus = NexusClient::create('nxs_…')| Symbol | Kind | Summary |
|---|---|---|
NexusClient | class | The Nexus server-side SDK. |
Config | class | Immutable SDK configuration. |
Services | class | Per-service on/off switches — turn a Nexus product off without removing the code that uses it. |
NexusClient
classclass Inverge\Nexus\NexusClientThe Nexus server-side SDK. Framework-agnostic: construct once with an API key and use any resource.
$nexus = NexusClient::create('nxs_live_...');
$nexus->realtime()->emit('orders:42', 'status', ['state' => 'shipped']);
$nexus->events()->capture('order_placed', ['total' => 42.0], ['distinctId' => 'u_1']);
$flags = $nexus->flags()->evaluate('u_1');__construct
constructorfunction __construct(Inverge\Nexus\Config $config, ?Inverge\Nexus\Contracts\Transport $transport = NULL, ?Inverge\Nexus\Contracts\Dispatcher $dispatcher = NULL)Parameters
Prop
Type
create()
static methodstatic function create(string $apiKey, array $options = []): selfConvenience factory using the built-in cURL transport.
Parameters
Prop
Type
Returns self
withDispatcher()
methodfunction withDispatcher(Inverge\Nexus\Contracts\Dispatcher $dispatcher): selfA clone that delivers through a different dispatcher — e.g. a queued one for fire-and-forget telemetry. Result-returning calls (flags, sessions) shouldn't be used on a deferred dispatcher since they can't return.
Parameters
Prop
Type
Returns self
realtime()
methodfunction realtime(): Inverge\Nexus\Resource\RealtimeReturns Inverge\Nexus\Resource\Realtime
events()
methodfunction events(): Inverge\Nexus\Resource\EventsReturns Inverge\Nexus\Resource\Events
errors()
methodfunction errors(): Inverge\Nexus\Resource\ErrorsReturns Inverge\Nexus\Resource\Errors
logs()
methodfunction logs(): Inverge\Nexus\Resource\LogsReturns Inverge\Nexus\Resource\Logs
sessions()
methodfunction sessions(): Inverge\Nexus\Resource\SessionsReturns Inverge\Nexus\Resource\Sessions
flags()
methodfunction flags(): Inverge\Nexus\Resource\FlagsReturns Inverge\Nexus\Resource\Flags
links()
methodfunction links(): Inverge\Nexus\Resource\LinksReturns Inverge\Nexus\Resource\Links
surveys()
methodfunction surveys(): Inverge\Nexus\Resource\SurveysReturns Inverge\Nexus\Resource\Surveys
remoteConfig()
methodfunction remoteConfig(): Inverge\Nexus\Resource\RemoteConfigReturns Inverge\Nexus\Resource\RemoteConfig
push()
methodfunction push(): Inverge\Nexus\Resource\PushReturns Inverge\Nexus\Resource\Push
inApp()
methodfunction inApp(): Inverge\Nexus\Resource\InAppReturns Inverge\Nexus\Resource\InApp
liveActivities()
methodfunction liveActivities(): Inverge\Nexus\Resource\LiveActivitiesReturns Inverge\Nexus\Resource\LiveActivities
telescope()
methodfunction telescope(array $options = []): Inverge\Nexus\Telescope\TelescopeRequest-journey tracing (Nexus Telescope). The Laravel and Symfony
integrations drive it automatically; call it directly anywhere else.
Options apply the first time it is created (see Telescope::__construct()).
Parameters
Prop
Type
Returns Inverge\Nexus\Telescope\Telescope
config()
methodfunction config(): Inverge\Nexus\ConfigReturns Inverge\Nexus\Config
enabled()
methodfunction enabled(string $service): boolWhether a product is switched on (see Services) — e.g. to skip
building an expensive payload: if ($nexus->enabled(Services::PUSH)) ….
Parameters
Prop
Type
Returns bool
Config
classclass Inverge\Nexus\ConfigImmutable SDK configuration. Partner endpoints live under /partner on the
base URL and authenticate with the x-api-key header.
__construct
constructorfunction __construct(string $apiKey, string $baseUrl = 'https://services.inverge.net', float $timeout = 10.0, array $defaultHeaders = [], ?Inverge\Nexus\Services $services = NULL)Parameters
Prop
Type
fromArray()
static methodstatic function fromArray(string $apiKey, array $options = []): selfservices switches products off, e.g. ['push' => false] (unset = from the
environment); enabled => false turns everything off.
Parameters
Prop
Type
Returns self
services()
methodfunction services(): Inverge\Nexus\ServicesThe effective switches: the explicit ones, else the environment's (read once). */
Returns Inverge\Nexus\Services
httpBase()
methodfunction httpBase(): stringThe base URL without a trailing slash. */
Returns string
Services
classclass Inverge\Nexus\ServicesPer-service on/off switches — turn a Nexus product off without removing the code that uses it. A disabled service makes no network call and never throws: writes are skipped and reads return their neutral value (flags → defaults, Remote Config → defaults, lists → empty).
From the environment (all default to on):
NEXUS_ENABLED=false # everything off NEXUS_PUSH_ENABLED=false # only push off NEXUS_LIVE_ACTIVITIES_ENABLED=false # only Live Activities off
One variable per service — see self::ENV. false, 0, off and no
mean off; anything else (or unset) means on.
| Constant | Value |
|---|---|
0 | \{"name":"REALTIME","value":"realtime"\} |
1 | \{"name":"EVENTS","value":"events"\} |
2 | \{"name":"ERRORS","value":"errors"\} |
3 | \{"name":"LOGS","value":"logs"\} |
4 | \{"name":"SESSIONS","value":"sessions"\} |
5 | \{"name":"FLAGS","value":"flags"\} |
6 | \{"name":"REMOTE_CONFIG","value":"remote_config"\} |
7 | \{"name":"LINKS","value":"links"\} |
8 | \{"name":"SURVEYS","value":"surveys"\} |
9 | \{"name":"PUSH","value":"push"\} |
10 | \{"name":"IN_APP","value":"in_app"\} |
11 | \{"name":"LIVE_ACTIVITIES","value":"live_activities"\} |
12 | \{"name":"TELESCOPE","value":"telescope"\} |
13 | \{"name":"ENV","value":"\{\\"realtime\\":\\"NEXUS_REALTIME_ENABLED\\",\\"events\\":\\"NEXUS_EVENTS_ENABLED\\",\\"errors\\":\\"NEXUS_ERRORS_ENABLED\\",\\"logs\\":\\"NEXUS_LOGS_ENABLED\\",\\"sessions\\":\\"NEXUS_SESSIONS_ENABLED\\",\\"flags\\":\\"NEXUS_FLAGS_ENABLED\\",\\"remote_config\\":\\"NEXUS_REMOTE_CONFIG_ENABLED\\",\\"links\\":\\"NEXUS_LINKS_ENABLED\\",\\"surveys\\":\\"NEXUS_SURVEYS_ENABLED\\",\\"push\\":\\"NEXUS_PUSH_ENABLED\\",\\"in_app\\":\\"NEXUS_IN_APP_ENABLED\\",\\"live_activities\\":\\"NEXUS_LIVE_ACTIVITIES_ENABLED\\",\\"telescope\\":\\"NEXUS_TELESCOPE_ENABLED\\"\}"\} |
14 | \{"name":"ENV_ALL","value":"NEXUS_ENABLED"\} |
allEnabled()
static methodstatic function allEnabled(): selfEverything on. */
Returns self
fromArray()
static methodstatic function fromArray(array $switches, string|int|bool|null $enabled = true): selfFrom switches, e.g. ['push' => false] (unknown keys are rejected so a
typo can't silently leave a service on). enabled is the master switch.
Parameters
Prop
Type
Returns self
fromEnvironment()
static methodstatic function fromEnvironment(?array $env = NULL): selfFrom environment variables (getenv, then $_ENV / $_SERVER).
Parameters
Prop
Type
Returns self
forPath()
static methodstatic function forPath(string $path): ?stringThe service a /partner/... path belongs to, or null for unswitched paths. */
Parameters
Prop
Type
Returns ?string
enabled()
methodfunction enabled(string $service): boolParameters
Prop
Type
Returns bool
reason()
methodfunction reason(string $service): stringWhy a service is off — for logs. */
Parameters
Prop
Type
Returns string
