somnambulist/api-client
Somnambulist API Client gives Laravel and PHP developers a structured, testable way to consume external HTTP APIs. Define requests, send them cleanly, handle responses consistently, and keep third-party integrations maintainable without scattering HTTP logic through your app.
Http::get() calls scattered across services, or do we invest in a typed client abstraction (resource + endpoint + response objects, hydrators, pagination)? The package is evidence that the abstraction can be built cheaply in PHP — it is small, MIT-licensed, and pattern-oriented rather than feature-heavy.Consider it as a design reference or a starting scaffold, not as a dependency, when:
Http:: calls start to diverge.Resource per vendor, an Endpoint per operation, a typed Response, and hydration into domain models rather than arrays.Look elsewhere if any of the following is true — and for most production contexts, several will be:
Http client plus a thin service class covers the majority of needs; Saloon is the mature, actively maintained Laravel/PHP package for exactly this problem (connectors, requests, auth, retries, caching, testing fakes). Choose Saloon for adoption; use this package as a pattern reference.Net: reasonable for a spike or an internal pattern write-up; not reasonable as a named production dependency.
To executives — one paragraph: We evaluated a small open-source PHP library that structures outbound API integrations into consistent, testable pieces. It is well-designed but effectively unmaintained (1 GitHub star, no downstream dependents), so I do not recommend adopting it as a dependency. I do recommend adopting the pattern it demonstrates — one typed client per vendor, one response envelope, one pagination contract — implemented on top of Laravel's HTTP client or the maintained Saloon package. This costs roughly the same as our current ad-hoc approach, reduces the cost of each future integration, and avoids the vendor risk of a single-maintainer library.
To engineering — the substance: Treat somnambulist/api-client as a spec, not a package. It proposes: a client object holding transport config; a Resource per upstream service; an Endpoint per operation encapsulating method, path, and query; a typed response object; and hydration into domain models with pagination as a first-class object. That decomposition is the valuable artefact. Reproduce it with Saloon connectors/requests (or Laravel Http + invokable request classes), keep hydration explicit, and add the operational concerns the library omits: retries, timeouts, auth refresh, rate-limit handling, and Http::fake()-based contract tests. Document it as an internal convention so the third integration is cheaper than the first.
To security/procurement: No new third-party dependency proposed. The pattern uses first-party or already-vetted packages. If we later want the library itself, flag that it is single-maintainer with no downstream adoption and should go through standard open-source risk review — but note that our current recommendation makes that request unnecessary.
How can I help you explore Laravel packages today?