When I work with APIs, I usually create a single PHP class which is responsible for sending the Guzzle HTTP request. It usually looks like this: <?php namespace App\Services\IMDB; use GuzzleHttp\Client; use GuzzleHttp\Psr7\Response; class HttpClient { public function send(array $payload) : Response { return app(Client::class) ->request('POST', 'https://api.example.com/movies', $payload); } } I don't write Unit Tests for such a simple class, but I will write Integration Tests to cover the feature, which will trigger the class in some way or another. When I want to test how my app reacts ...
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners