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

jove's avatar
Level 7

Best way to test code that relies on external API

So I know that you shouldn't test external APIs, but how do you test your own code when it relies on external APIs and do a lot of stuff? I do not want to not test my part here.

In my case I'm using discord and this library restcord/restcord. But I don't want to be stuck with going through all my code and manually test it against the real discord each time I do changes.

Example, my main dashboard view, I want to know that I can view it fine, but this does a minimum of 3 API calls to discord before it's cached.

0 likes
2 replies
jove's avatar
Level 7

Maybe some type of mocking API service would be the best way

I was hoping that the Http::fake() was what I was looking for, but it was sadly only for mocking the laravel http client :(

jove's avatar
Level 7

Found this service https://mockoon.com/ Gonna check it out, seems to be my solution (if there are not better and maybe native way)

Please or to participate in this conversation.