Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

preston_brown's avatar

Using Laravel Resources to consume 3rd party API OUTSIDE of a controller

Perhaps a silly question everyone, but I've read Jeff Ochoa's article about consuming 3rd party APIs and encapsulating response data inside Laravel resources (https://medium.com/@jeffochoa/consuming-third-pary-apis-with-laravel-resources-c13a0c7dc945).

I don't see how it is possible to do this without a Request in context. Sometimes I will want to make 3rd party API calls and consume the response outside the context of a controller action/method. Any ideas on how to make that work? I could of course build my own abstraction w/o Laravel Resources but the various built-in methods they provide look handy.

0 likes
2 replies
Punksolid's avatar

In theory you wouldn't have any problem using it in another context like inside a method in a model.

Please or to participate in this conversation.