Skip to content

Instantly share code, notes, and snippets.

@odixon
Created October 11, 2018 12:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save odixon/16422dff4c5e91344ca13f4126d2e151 to your computer and use it in GitHub Desktop.
Save odixon/16422dff4c5e91344ca13f4126d2e151 to your computer and use it in GitHub Desktop.
Guzzle with http errors off
<?php
// create client
$client = new \GuzzleHttp\Client();
$res = $client->request('GET', $someApi, ['http_errors' => false]);
// check http status code
if ($res->getStatusCode() != 200) {
// handle it
}
$res = $client->request('GET', $anotherApi, ['http_errors' => false]);
if ($res->getStatusCode() != 200) {
// handle it
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment