PHP and Node.js: what each SDK supports

PHP

Every call of the two SDKs side by side, and what else tells them apart — the runtime, the HTTP client, the journal, the spans, Laravel.

Slen has two SDKs, for PHP and for Node.js. They call the same API, have the same calls, raise the same type of error for each code and write the same journal and the same spans. This page compares them.

The calls

A call is named the same way in both SDKs: operations.execute is slen.operations.execute() in Node.js and $slen->operations()->execute() in PHP.

MethodPHPNode.js
customers.adjustYesYes
customers.blockYesYes
customers.chargeYesYes
customers.createYesYes
customers.deleteYesYes
customers.entriesYesYes
customers.getYesYes
customers.listYesYes
customers.pricesYesYes
customers.topUpYesYes
customers.unblockYesYes
customers.updateAccountYesYes
executions.getYesYes
executions.traceYesYes
executions.waitYesYes
flushNoYes
healthYesYes
operations.executeYesYes
operations.executeAsyncYesYes
webhooks.constructEventYesYes
webhooks.verifyYesYes

Client and methods lists the calls of one SDK with the request each one makes.

What else differs

WhatPHPNode.js
The packageslen/sdk@slen/sdk
The runtimePHP 8.3 or laterNode.js 20.3 or later
The HTTP clientAny PSR-18 client of your application: Guzzle, Symfony HttpClient or anotherThe fetch of the runtime
The key from the environmentNo: pass it to SlenConfig. In Laravel the config file reads itYes, SLEN_API_KEY — Configuration
The logger of the journalA PSR-3 loggerconsole, or an object with the same four methods
Spans written to a logYes, Psr3SpanRecorderYes, LoggerSpanRecorder
Spans sent to OpenTelemetryNo: implement a recorder of your ownYes, over OTLP or into the traces of your application — Spans
Sending what a recorder holds before exitNot needed: a span is written at onceflush()
A wait without a time limitNo: the limit of a wait is a whole number of secondsYes, timeoutSeconds set to Infinity
Ending a call or a wait from outsideNoYes, signal
A timeout of one callYes, timeout of the options of the callYes, timeoutMs of the call
The repeats of one callYes, retries of the options of the callYes, retries of the call
A receiver of webhooks without an API keyWebhooksFacade::standalone(), its secret in WebhooksOptionswebhooks, exported by the package, the secret in the options of each call
Laravel: a service provider, a facade and a config fileYes — Laravel integrationNo
A test double of the networkFakeHttpClientFakeFetch — Testing your integration
The result of a callAn object with properties in camel caseThe answer of the API, with its field names

What the two have in common: the same error types for the same codes (Error types), the same events of the journal (Logging), the same ten fields of a span (Spans), and the same rules for what is sent again (Retries and timeouts).

Where to go next

Built from openapi b070e1f, sdk contract 6a2e0e0, php 4089db3, node 0fa87be