PHP and Node.js: what each SDK supports
PHPEvery 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.
| Method | PHP | Node.js |
|---|---|---|
customers.adjust | Yes | Yes |
customers.block | Yes | Yes |
customers.charge | Yes | Yes |
customers.create | Yes | Yes |
customers.delete | Yes | Yes |
customers.entries | Yes | Yes |
customers.get | Yes | Yes |
customers.list | Yes | Yes |
customers.prices | Yes | Yes |
customers.topUp | Yes | Yes |
customers.unblock | Yes | Yes |
customers.updateAccount | Yes | Yes |
executions.get | Yes | Yes |
executions.trace | Yes | Yes |
executions.wait | Yes | Yes |
flush | No | Yes |
health | Yes | Yes |
operations.execute | Yes | Yes |
operations.executeAsync | Yes | Yes |
webhooks.constructEvent | Yes | Yes |
webhooks.verify | Yes | Yes |
Client and methods lists the calls of one SDK with the request each one makes.
What else differs
| What | PHP | Node.js |
|---|---|---|
| The package | slen/sdk | @slen/sdk |
| The runtime | PHP 8.3 or later | Node.js 20.3 or later |
| The HTTP client | Any PSR-18 client of your application: Guzzle, Symfony HttpClient or another | The fetch of the runtime |
| The key from the environment | No: pass it to SlenConfig. In Laravel the config file reads it | Yes, SLEN_API_KEY — Configuration |
| The logger of the journal | A PSR-3 logger | console, or an object with the same four methods |
| Spans written to a log | Yes, Psr3SpanRecorder | Yes, LoggerSpanRecorder |
| Spans sent to OpenTelemetry | No: implement a recorder of your own | Yes, over OTLP or into the traces of your application — Spans |
| Sending what a recorder holds before exit | Not needed: a span is written at once | flush() |
| A wait without a time limit | No: the limit of a wait is a whole number of seconds | Yes, timeoutSeconds set to Infinity |
| Ending a call or a wait from outside | No | Yes, signal |
| A timeout of one call | Yes, timeout of the options of the call | Yes, timeoutMs of the call |
| The repeats of one call | Yes, retries of the options of the call | Yes, retries of the call |
| A receiver of webhooks without an API key | WebhooksFacade::standalone(), its secret in WebhooksOptions | webhooks, exported by the package, the secret in the options of each call |
| Laravel: a service provider, a facade and a config file | Yes — Laravel integration | No |
| A test double of the network | FakeHttpClient | FakeFetch — Testing your integration |
| The result of a call | An object with properties in camel case | The 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
Overview — what you do with the SDK.
Installation — what each SDK needs.
Client and methods — every call of one SDK.
Built from openapi b070e1f, sdk contract 6a2e0e0, php 4089db3, node 0fa87be