InvergeDocs
PHPAPI reference

NexusClient

NexusClient in the PHP SDK.

// access
$nexus = NexusClient::create('nxs_…')
SymbolKindSummary
NexusClientclassThe Nexus server-side SDK.
ConfigclassImmutable SDK configuration.
ServicesclassPer-service on/off switches — turn a Nexus product off without removing the code that uses it.

NexusClient

class
class Inverge\Nexus\NexusClient

The 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');
View source

__construct

constructor
function __construct(Inverge\Nexus\Config $config, ?Inverge\Nexus\Contracts\Transport $transport = NULL, ?Inverge\Nexus\Contracts\Dispatcher $dispatcher = NULL)

Parameters

Prop

Type

View source

create()

static method
static function create(string $apiKey, array $options = []): self

Convenience factory using the built-in cURL transport.

Parameters

Prop

Type

Returns self

View source

withDispatcher()

method
function withDispatcher(Inverge\Nexus\Contracts\Dispatcher $dispatcher): self

A 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

View source

realtime()

method
function realtime(): Inverge\Nexus\Resource\Realtime

Returns Inverge\Nexus\Resource\Realtime

View source

events()

method
function events(): Inverge\Nexus\Resource\Events

Returns Inverge\Nexus\Resource\Events

View source

errors()

method
function errors(): Inverge\Nexus\Resource\Errors

Returns Inverge\Nexus\Resource\Errors

View source

logs()

method
function logs(): Inverge\Nexus\Resource\Logs

Returns Inverge\Nexus\Resource\Logs

View source

sessions()

method
function sessions(): Inverge\Nexus\Resource\Sessions

Returns Inverge\Nexus\Resource\Sessions

View source

flags()

method
function flags(): Inverge\Nexus\Resource\Flags

Returns Inverge\Nexus\Resource\Flags

View source method
function links(): Inverge\Nexus\Resource\Links

Returns Inverge\Nexus\Resource\Links

View source

surveys()

method
function surveys(): Inverge\Nexus\Resource\Surveys

Returns Inverge\Nexus\Resource\Surveys

View source

remoteConfig()

method
function remoteConfig(): Inverge\Nexus\Resource\RemoteConfig

Returns Inverge\Nexus\Resource\RemoteConfig

View source

push()

method
function push(): Inverge\Nexus\Resource\Push

Returns Inverge\Nexus\Resource\Push

View source

inApp()

method
function inApp(): Inverge\Nexus\Resource\InApp

Returns Inverge\Nexus\Resource\InApp

View source

liveActivities()

method
function liveActivities(): Inverge\Nexus\Resource\LiveActivities

Returns Inverge\Nexus\Resource\LiveActivities

View source

telescope()

method
function telescope(array $options = []): Inverge\Nexus\Telescope\Telescope

Request-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

View source

config()

method
function config(): Inverge\Nexus\Config

Returns Inverge\Nexus\Config

View source

enabled()

method
function enabled(string $service): bool

Whether 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

View source

Config

class
class Inverge\Nexus\Config

Immutable SDK configuration. Partner endpoints live under /partner on the base URL and authenticate with the x-api-key header.

View source

__construct

constructor
function __construct(string $apiKey, string $baseUrl = 'https://services.inverge.net', float $timeout = 10.0, array $defaultHeaders = [], ?Inverge\Nexus\Services $services = NULL)

Parameters

Prop

Type

View source

fromArray()

static method
static function fromArray(string $apiKey, array $options = []): self

services switches products off, e.g. ['push' => false] (unset = from the environment); enabled => false turns everything off.

Parameters

Prop

Type

Returns self

View source

services()

method
function services(): Inverge\Nexus\Services

The effective switches: the explicit ones, else the environment's (read once). */

Returns Inverge\Nexus\Services

View source

httpBase()

method
function httpBase(): string

The base URL without a trailing slash. */

Returns string

View source

Services

class
class Inverge\Nexus\Services

Per-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.

ConstantValue
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"\}
View source

allEnabled()

static method
static function allEnabled(): self

Everything on. */

Returns self

View source

fromArray()

static method
static function fromArray(array $switches, string|int|bool|null $enabled = true): self

From 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

View source

fromEnvironment()

static method
static function fromEnvironment(?array $env = NULL): self

From environment variables (getenv, then $_ENV / $_SERVER).

Parameters

Prop

Type

Returns self

View source

forPath()

static method
static function forPath(string $path): ?string

The service a /partner/... path belongs to, or null for unswitched paths. */

Parameters

Prop

Type

Returns ?string

View source

enabled()

method
function enabled(string $service): bool

Parameters

Prop

Type

Returns bool

View source

reason()

method
function reason(string $service): string

Why a service is off — for logs. */

Parameters

Prop

Type

Returns string

View source

On this page