Download the PHP package uengage.io/php-platform-sdk without Composer

On this page you can find all versions of the php package uengage.io/php-platform-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package php-platform-sdk

uengage.io/php-platform-sdk

Backend-issued public/private suggestion tokens and outlet, brand or global admin tokens: upsell token guide.

PHP client SDK for the uEngage platform API. Mirrors the JS SDK (@uengage.io/platform-sdk) — same five namespaces (zones, business, audit, auth, wallet), same auth modes, same error envelope.

Restricted realtime channels

Use $platform->auth->mintRealtimeToken($clientId, $clientSecret, 'delivery-updates', 300) on your backend after authorizing the current user's access to that channel. The client must be registered with realtime.tokens:issue. The result is ['token' => ..., 'expiresIn' => 300, 'channel' => 'delivery-updates'] and can be returned from a non-cacheable same-origin token route. Credentials stay server-side.

Names are case-sensitive identifiers, not paths or wildcards. Tokens permit exactly one name, are valid for 60–14400 seconds (300 by default), and cannot publish or call other platform APIs. Minting does not create a publisher. See the complete integration and authorization guide.

Install

If you have not configured Packagist yet, point at the mirror repo directly in composer.json:

Quick start

Configuration

Client::create([...]) takes the same options as the JS SDK:

Option Type Default
baseUrl string https://api.platform.uengage.io
authBaseUrl string {baseUrl}/auth/business
customerAuthBaseUrl string {baseUrl}/auth/customer
serviceId + serviceSecret string OAuth2 client_credentials mode
authToken string static Bearer mode (caller owns freshness)
session ['id' => ..., 'token' => ...] legacy uEngage session-exchange mode
getToken callable renews a static vault token (see Vault); not with serviceId
scope string (optional) space-separated scope list for client_credentials
actorVia string stamped into audit actor.via
cache TokenCacheInterface APCu if loaded, else file-on-disk
http HttpClient default (cURL backend)
eventsTopicArn string SNS topic ARN for the platform event bus
eventsRegion string defaults to the region inside eventsTopicArn
eventSource string envelope source field, default legacy-php
snsPublisher SnsPublisherInterface default: AwsSnsPublisher (aws/aws-sdk-php)
alertsQueueUrl string alerts SQS FIFO queue for alerts->raise()
env uat | prod picks the default alerts queue
sqsSender SqsSenderInterface default: AwsSqsSender (aws/aws-sdk-php)

Auth modes are mutually exclusive. Picking more than one throws ConfigException. Picking zero is allowed - the client only works against public endpoints (the openapi spec).

Env defaults (read by Client::create() when an option is omitted): UENGAGE_BASE_URL, UENGAGE_AUTH_BASE_URL, UENGAGE_CUSTOMER_AUTH_BASE_URL, UENGAGE_SERVICE_ID, UENGAGE_SERVICE_SECRET, UENGAGE_SCOPE, UENGAGE_AUTH_TOKEN, UENGAGE_SESSION_ID, UENGAGE_SESSION_TOKEN, UENGAGE_ACTOR_VIA, PLATFORM_EVENTS_TOPIC_ARN, PLATFORM_EVENTS_REGION, PLATFORM_EVENTS_SOURCE, PLATFORM_ALERTS_QUEUE_URL, UENGAGE_ENV.

Events client (platform event bus)

Publishes order-lifecycle events onto the platform's SNS bus. This is the one namespace that does not go through the platform HTTP API — it publishes straight to SNS with the host's AWS credentials (on legacy, the EC2 instance role), so there is no token to mint and no extra hop on the order path.

Requires aws/aws-sdk-php

It is a suggested, not a required, dependency: this SDK is installed by consumers that only use zones/business/audit, and a hard requirement would drag the AWS SDK — and its PHP >= 7.2.5 floor — into all of them. Applications that publish events or raise alerts add it themselves:

Without it, publish() still buffers and flush() fails open with an error_log() entry. Hosts that already own a configured SnsClient can pass 'snsPublisher' => new AwsSnsPublisher($region, $existingClient), or any SnsPublisherInterface.

Alerts client

Raise operational alerts (low wallet balance, dead payment-gateway credentials, ...) and read / resolve them from a dashboard backend. Two transports:

Call Transport Needs
raise() SQS FIFO queue alerts-{env}.fifo host AWS identity with sqs:SendMessage on it, aws/aws-sdk-php
list(), get() GET /v1/alerts[/{id}] Bearer token with alerts:read
setStatus() POST /v1/alerts/{id}/status Bearer token with alerts:write

Raising

raise() sends the alert straight to the alerts SQS FIFO queue — no SNS, no event bus, no HTTP call — and otherwise behaves like the events client above:

Queue URL, first match wins (same order as the TS SDK):

  1. the alertsQueueUrl option, else PLATFORM_ALERTS_QUEUE_URL;
  2. the default for the env option, else UENGAGE_ENV (AlertsClient::ALERT_QUEUE_URLS):
    • uat: https://sqs.ap-south-1.amazonaws.com/571896969292/alerts-uat.fifo
    • prod: https://sqs.ap-south-1.amazonaws.com/822426641710/alerts-prod.fifo
  3. otherwise (no env, or an unknown one such as dev) there is no queue and every raised alert is logged and counted as failed at flush.

The AWS region comes from the queue URL host (sqs.<region>.amazonaws.com), else AWS_REGION. Credentials come from the AWS SDK's default chain. A queue URL on a non-AWS host (LocalStack, ElasticMQ) is also used as the SQS endpoint.

IAM. The host's AWS identity needs sqs:SendMessage on arn:aws:sqs:ap-south-1:<account>:alerts-{env}.fifo (SendMessageBatch is authorised by sqs:SendMessage). The queue lives in the platform account, so a producer in another AWS account (e.g. the legacy stack) also has to be listed in the alerts queue's resource policy — the platform grants it to the roles in its producer role list; ask for your role to be added. The SDK auth modes are not used for raising. Hosts that own a configured SqsClient can pass 'sqsSender' => new AwsSqsSender(null, $existingClient), or any SqsSenderInterface.

Matching. The service keys an alert on (businessId, parentId, type). While an alert with that identity is open or muted, a new message adds to its count, moves lastSeenAt and updatedAt, and the latest title, description, context and notify win. Once it is resolved, the next raise() starts a new alert row (fresh id, count 1). Title, description and context therefore do not split alerts — put volatile values in context freely.

Listing and resolving

An alert is {id, parentId, businessId, title, description, type, category, context, notify, status, count, firstSeenAt, lastSeenAt, updatedAt, userIds} plus resolvedAt/resolvedBy/resolutionComment, mutedAt/mutedBy/muteComment and reopenedAt/reopenedBy/reopenComment when set. count is the number of messages received while it was open or muted; firstSeenAt / lastSeenAt are the occurredAt of its first and latest message; updatedAt is the last change of any kind. id ({businessId}.{type}#{ulid}) is stable.

userIds lists the dashboard users who can see the alert. The service decides it once, when the alert row starts, from its audience rules: a rule for the alert's business + type if one exists, else one for its parent + type, else a default list. Count bumps never change it, and changing the rules (a service deploy) only affects alert rows started afterwards. A userId list page may hold fewer than limit items while nextCursor is still set — keep paging until it is null.

Status changes: open ↔ muted and open|muted → resolved always work. Reopening (resolved → open, comment optional) works only while no other open or muted alert of the same identity exists — if a later raise() already started a new one, the service answers 409 newer_alert_open with that alert's id:

These use the normal auth modes; the service's token needs alerts:read for list()/get() and alerts:write for setStatus(). Non-2xx responses throw Uengage\PlatformSdk\Alerts\AlertsApiException (getStatus(), getBody(), getErrorCode()).

Upsell client

Cart-aware upsell suggestions. Three calls carry a storefront integration: ask which slots exist, ask what goes in one, report what happened.

Six things that are not obvious from the types:

Admin plane

Placement configuration. These require a service-actor token carrying upsell.placements:read / :write; a user token gets a 403.

adminUpsertPlacement is a full replace, not a patch — channel, key, touchpoint, enabled and display are required on every call, so a partial object is a 400 rather than a merge. Only strategy, strategyParams, display.maxItems and display.layout have server-side defaults. Scope is derived from what you send: no parentId is the platform default, parentId alone is a brand rule, parentId + businessId is one outlet.

Deleting without a parentId targets the platform default, removing the placement for every tenant that has not overridden it, and needs 'confirmDeleteDefault' => true. This client only sends that flag when you pass it truthy, so forgetting parentId gets you a 400 rather than a silent wipe.

Non-2xx responses throw UpsellApiException (getStatus(), getBody()).

Wallet + credit line

getWallet(...) is a lightweight handle — no I/O. The wallet resolves server-side on the first operation.

Which billing model? — start here

Prepaid wallets and merchant credit lines coexist, and which one a merchant is on decides what to render and which calls are legal.

Credit line

The ceiling is per merchant, not per wallet, so an outlet's id and its parent's id return the same line.

Refusals worth branching on

WalletApiException::errorCode() gives the machine-readable code; creditFigures() gives the credit-line figures on credit_limit_reached.

credit_line_not_found (404) is a prepaid merchant, not a failure — use getOverview() and you never see it.

Money

Every figure is ['amount' => float, 'amountMinor' => int]. Compute in amountMinor (integer paise); amount is for display. On a ledger row amount is gross and breakup.subTotalMinor is what consumed the ceiling — creditMerchantId present means that row's balanceBefore/balanceAfter are available credit, not a wallet balance.

Vault (credentials and KYC documents)

$platform->vault stores per-brand payment-gateway / POS credentials and KYC documents encrypted, and hands plaintext back only to tokens that carry a vault.<class>:decrypt scope. Vault accepts only vault tokens, each bound to one tenant: a brand (parentId) or one of its outlets (parentId + businessId). A brand token reaches the brand's items and every outlet's; an outlet token reaches only that outlet.

Backend: client credentials

The SDK mints a vault token for that tenant (urn:uengage:params:oauth:grant-type:vault-business, every vault scope your client's registry entry allows), caches it in the configured token cache until 60 s before expiry, and re-mints once on a 401. Your client needs vault.tokens:issue plus the vault scopes in the auth registry.

List filters: type or class (one is required), tags (sent as tag.<key>=<value>), status, businessId, includeOutlets (brand token only), limit (≤ 100), cursor. list() returns one page (['items' => ..., 'nextCursor' => ...]); listAll() is a generator that follows nextCursor.

Decrypt and SecretValue

Every decrypted field is a Uengage\PlatformSdk\Vault\SecretValue. Only ->reveal() returns the plaintext; (string), string interpolation, json_encode, print_r and var_dump all show [REDACTED], the plaintext is not held in an object property (so var_export and (array) casts do not show it), and serialize() / clone are refused. Call reveal() at the point of use and do not store, log or cache the result. Only the active version of an active credential is ever decrypted.

Frontend handoff: mintVaultToken

A backend mints a narrow, short-lived vault token and hands it to a frontend or another service, the same way as mintUpsellToken / mintRealtimeToken:

Never put a vault.<class>:decrypt scope in a token bound for a browser; the dashboard backend's client should not be granted it at all. The client needs vault.tokens:issue; tokens are never cached. Bad ids, non-vault scopes, an out-of-range expiresIn or an invalid onBehalfOf (1-128 printable ASCII characters) throw InvalidArgumentException before sending; a refused mint or a response that does not match the request throws AuthApiException.

Frontend handoff: mintAlertToken

A backend mints a short-lived alerts token for one dashboard user and hands it to that user's frontend. The token only reaches alerts whose userIds include that user (see the alerts audience rules): list is limited to them, and get / setStatus answer 404 for anyone else's. Status changes made with it are recorded as that user, so the frontend sends no actor.

The frontend uses the TypeScript SDK's browser-safe subpath:

The issuing client needs alerts.tokens:issue plus each alerts:* scope it puts in a token; tokens are never cached. A bad userId, a non-alerts scope, an out-of-range expiresIn or an invalid onBehalfOf throw InvalidArgumentException before sending; a refused mint or a response that does not match the request throws AuthApiException.

Static-token mode

A process that was handed a vault token uses it directly; the tenant comes from the token:

getToken is called when the token has expired and once after a 401 (the request is then retried once). Without it, a 401 is final.

Documents (KYC)

upload() is one call: it registers the document (POST /documents, which returns a presigned S3 POST), sends the file straight to S3 (no bearer), then calls POST /documents/{id}/complete, which checks the object's size and content type (409 upload_not_found / upload_mismatch). view() works only for uploaded documents; a pending one answers 409 document_not_uploaded. getByReference, list, listAll and setTags work as for credentials; the list status filter takes pending or uploaded.

Types

With client credentials, $platform->vault->types() uses the ordinary service token (it needs vault.types:read / vault.types:write); a tenant handle's types() uses its vault token.

Errors

Exception When
VaultDeniedException 403 - every denial is {"error":"forbidden"}; the reason is audited
VaultNotFoundException 404
VaultConflictException 409 - reference_conflict, version_conflict, credential_disabled, document_not_uploaded, upload_not_found, upload_mismatch
VaultValidationException 400 / 422 - bad input, unknown_type
VaultUnavailableException 5xx, or no response at all (status 0)

All extend VaultApiException (getStatus(), getBody(), getErrorCode()), which extends ApiException. Token-mint failures throw AuthenticationException; bad local input (ids, expiresIn, scopes) throws ConfigException before any request.

Token caching

By default Client::create() picks the best available cache:

  1. APCu (Uengage\PlatformSdk\Token\ApcuTokenCache) - if ext-apcu is loaded and enabled. Shared across PHP-FPM workers on the host; recommended for production.
  2. File (Uengage\PlatformSdk\Token\FileTokenCache) - falls back to sys_get_temp_dir()/uengage-platform-sdk-php/. Atomic writes, 0600 permissions. Works everywhere.

Plug a custom backend (Redis, Memcached, your app's cache pool) by implementing TokenCacheInterface and passing 'cache' => $yours to Client::create().

For one-off scripts or tests where multi-request reuse doesn't matter, use InMemoryTokenCache.

Error handling

The SDK throws typed exceptions:

Exception When
Uengage\PlatformSdk\Exceptions\ConfigException bad client construction (multiple auth modes, etc)
Uengage\PlatformSdk\Exceptions\AuthenticationException token mint rejected by auth surface
Uengage\PlatformSdk\Zones\ZonesApiException non-2xx from /v1/zones/*
Uengage\PlatformSdk\Wallet\WalletApiException non-2xx from /v1/wallet/* (->errorCode(), ->balanceMinor(), ->creditFigures())
Uengage\PlatformSdk\Business\BusinessApiException non-2xx from /v1/businesses/*
Uengage\PlatformSdk\Audit\AuditApiException non-2xx from /v1/audit/events
Uengage\PlatformSdk\Auth\AuthApiException non-2xx from /auth/business/*
Uengage\PlatformSdk\Vault\VaultApiException (+ subclasses) non-2xx from /v1/vault/* (->getErrorCode())
Uengage\PlatformSdk\Alerts\AlertsApiException non-2xx from /v1/alerts/*
InvalidArgumentException bad local input (non-uuid, out-of-range lat/lng, etc)

All *ApiException types extend ApiException and expose getStatus(): int + getBody(): string.

The SDK transparently rotates the token + retries once on a 401 when the auth mode supports invalidation, so most expiry-related 401s never surface to your code.

Testing the SDK locally

API surface — full reference

See /v1/zones/openapi.json, /v1/businesses/openapi.json, /v1/audit/openapi.json, /v1/upsell/openapi.json, /v1/alerts/openapi.json, /auth/business/openapi.json for the wire contracts. The PHP namespace structure mirrors the JS SDK 1:1 — refer to packages/platform-sdk/src/<namespace>/ for the canonical type shapes.


All versions of php-platform-sdk with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1
ext-curl Version *
ext-json Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package uengage.io/php-platform-sdk contains the following files

Loading the files please wait ...