Download the PHP package confish/sdk without Composer
On this page you can find all versions of the php package confish/sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package sdk
Short Description Official PHP SDK for confish — typed configuration, actions, logs, feeds, and webhook verification.
License MIT
Homepage https://confi.sh
Informations about the package sdk
confish/sdk
Official PHP SDK for confish — typed configuration, actions, logs, feeds, and webhook verification.
- Lean dependencies: Guzzle plus the PSR-3 interfaces
- Typed exceptions and automatic retry on
429/5xx - Monolog handler and PSR-3 logger — point logging you already have at confish
- Long-running action consumer with graceful-shutdown hook
- HMAC-SHA256 webhook verification (no extra deps)
Install
Requires PHP 8.1+.
Quick start
fetch, update, and replace return array<string, mixed>. PHPStan/Psalm users can document expected shapes via array shapes:
Reading and writing config
update and replace return the full updated configuration.
Write access must be enabled in environment settings before
updateandreplacewill work.
Feeds
Feeds hold living state — job statuses, crawl results, active incidents — keyed by your own external IDs. $client->feed($slug) returns a handle bound to one feed; no HTTP happens until you call a method on it.
set is a declarative full-replace: the item's data becomes exactly what you pass. ttl is in seconds (1 to 2592000 = 30 days); omitting it makes the item permanent and clears any TTL set by a previous set — TTLs are never carried over. External IDs are limited to 255 characters.
For sync-style cron jobs that push their full dataset each run, replace makes the feed exactly the items you pass in one request — no client-side diffing:
Anything absent from the payload is deleted, and an empty list clears the feed. The request is all-or-nothing: duplicate external_ids, more items than your plan's item cap, or any schema-invalid item rejects the whole request with a 422 and nothing written. The per-item ttl key follows the same rule as set — omit it to make that item permanent.
Each FeedItem exposes id, externalId, data (array<string, mixed>), expiresAt (nullable), createdAt, and updatedAt.
An unknown feed slug throws NotFoundException. A 422 throws ValidationException — with per-field messages in $e->errors when the item data doesn't match the feed's schema, or a message-only error when the feed is at its item cap.
Logging
Levels via the LogLevel enum: Debug, Info, Notice, Warning, Error, Critical, Alert, Emergency. Levels follow RFC 5424 (syslog), so they map 1:1 onto PSR-3/Monolog levels.
You can also write up to 100 entries in one request. level takes the enum or its string value; the optional ISO 8601 timestamp records when the entry was captured, for entries you buffered before sending:
Monolog / PSR-3
If you already log through Monolog, push Confish\MonologHandler onto your stack and everything you log flows to confish as well — no call-site changes:
The handler needs monolog/monolog ^3.0 (composer require monolog/monolog) — the SDK only suggests it, so you don't pull in Monolog unless you use the handler.
Records are buffered in memory with the timestamp captured at log time, then shipped through the batch endpoint: the handler flushes automatically at 50 buffered records (tune with flushAt:), on close(), and when it is destroyed at the end of the request — chunked to at most 100 entries per request. In long-running workers (queue consumers, daemons), call $handler->flush() on your own cadence or wrap the handler in Monolog's BufferHandler.
Delivery failures are swallowed, never thrown back into your logging path — a confish outage can't take down the work you're logging. Dropped entries are counted ($handler->droppedCount()) and reported to an optional callback, which is never routed back through the handler, so delivery errors can't feed back on themselves:
Not on Monolog? Confish\PsrLogger implements PSR-3's LoggerInterface and sends each record immediately, one request per call — fine for scripts and cron jobs; prefer the buffered Monolog handler for anything chatty. It gives the same never-throw guarantee, with droppedCount() and the same onError callback:
Both adapters pass context through structured — placeholders are not interpolated, and the dashboard renders the context object. Throwables under any context key are converted to class/message/file/line so they survive JSON encoding.
Laravel
Bind the client once, then point a monolog channel at the handler — no extra package or service provider needed:
Laravel resolves the handler through the container — injecting the bound Confish client and passing the channel's level — so scalar options are all handler_with needs. Log to it directly (Log::channel('confish')->info(...)) or add 'confish' to your stack channel to mirror everything you already log. Buffered records flush at the threshold and when the process shuts down; queue workers live across many jobs, so flush from a job hook or lower flushAt if you need entries sooner.
Actions
The action consumer polls for pending actions, acknowledges them, runs your handler, and reports completion or failure — including idempotent skip if another consumer claimed the same action first.
What happens automatically:
- A returned
arraybecomes the action'sresulton completion. - Throwing any exception fails the action with
['error' => $e->getMessage()]. - Throwing
SkipActionExceptionleaves the action acknowledged without resolving it. - A
409 Conflicton ack is silently skipped — safe to run multiple consumers. - The
shouldStopcallback is checked at the top of every poll; the loop exits cleanly. - After 3 consecutive empty polls the loop doubles its sleep up to
maxPollInterval, resetting topollIntervalthe moment any action is processed. Idle consumers make ~240 requests/hour by default.
You can also drive the lifecycle manually:
Webhook verification
Webhook::verify parses and verifies in one step: it returns the parsed WebhookPayload on success and throws on failure, so a bad signature can never be ignored.
Laravel example:
Failures are typed: WebhookSignatureException when the signature is missing, malformed, or doesn't match, and WebhookTimestampException when the signature matches but the timestamp is outside tolerance. Both extend WebhookVerificationException. Verification uses constant-time comparison and rejects timestamps older than 5 minutes by default — pass toleranceSeconds: 0 to disable. Always pass the raw, unparsed body — re-serializing parsed JSON breaks verification.
Errors
By default the client retries 429 (honoring Retry-After) and 5xx responses up to twice. Tune with maxRetries on the constructor.
Options
License
MIT
All versions of sdk with dependencies
ext-json Version *
guzzlehttp/guzzle Version ^7.5 || ^8.0
psr/log Version ^2.0 || ^3.0