{"id":30367206,"url":"https://github.com/elfsundae/httpclient","last_synced_at":"2026-07-08T21:31:22.614Z","repository":{"id":56976568,"uuid":"94341681","full_name":"ElfSundae/httpclient","owner":"ElfSundae","description":"A smart Guzzle wrapper.","archived":false,"fork":false,"pushed_at":"2022-02-19T21:03:17.000Z","size":105,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-28T04:37:21.775Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ElfSundae.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-06-14T14:45:11.000Z","updated_at":"2022-02-19T19:49:48.000Z","dependencies_parsed_at":"2022-08-21T10:20:53.391Z","dependency_job_id":null,"html_url":"https://github.com/ElfSundae/httpclient","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/ElfSundae/httpclient","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ElfSundae%2Fhttpclient","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ElfSundae%2Fhttpclient/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ElfSundae%2Fhttpclient/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ElfSundae%2Fhttpclient/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ElfSundae","download_url":"https://codeload.github.com/ElfSundae/httpclient/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ElfSundae%2Fhttpclient/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271236297,"owners_count":24723983,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-19T02:00:09.176Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-08-19T23:13:58.149Z","updated_at":"2025-10-18T13:02:27.299Z","avatar_url":"https://github.com/ElfSundae.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# HTTP Client\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/elfsundae/httpclient.svg?style=flat-square)](https://packagist.org/packages/elfsundae/httpclient)\n[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)\n[![tests](https://github.com/ElfSundae/httpclient/actions/workflows/tests.yml/badge.svg)](https://github.com/ElfSundae/httpclient/actions/workflows/tests.yml)\n[![StyleCI](https://styleci.io/repos/94341681/shield)](https://styleci.io/repos/94341681)\n[![SymfonyInsight Grade](https://img.shields.io/symfony/i/grade/45206378-96ff-4e07-b6a1-582fc5bde5f5?style=flat-square)](https://insight.symfony.com/projects/45206378-96ff-4e07-b6a1-582fc5bde5f5)\n[![Quality Score](https://img.shields.io/scrutinizer/g/ElfSundae/httpclient.svg?style=flat-square)](https://scrutinizer-ci.com/g/ElfSundae/httpclient)\n[![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/ElfSundae/httpclient/master.svg?style=flat-square)](https://scrutinizer-ci.com/g/ElfSundae/httpclient/?branch=master)\n[![Total Downloads](https://img.shields.io/packagist/dt/elfsundae/httpclient.svg?style=flat-square)](https://packagist.org/packages/elfsundae/httpclient)\n\nHttpClient is a smart [Guzzle](https://github.com/guzzle/guzzle) wrapper provides convenient method chaining, global request options, and magic methods to customize [request options][].\n\n## Installation\n\n```sh\n$ composer require elfsundae/httpclient\n```\n\n## Usage\n\n```php\nuse ElfSundae\\HttpClient;\n```\n\n### Fetching Response Content\n\n```php\n$html = (new HttpClient)-\u003efetchContent('http://httpbin.org');\n\n$data = (new HttpClient)-\u003efetchJson('https://httpbin.org/ip');\n```\n\n### Making Requests\n\n```php\n$client = HttpClient::create('https://httpbin.org')\n    -\u003ecatchExceptions(true)\n    -\u003ehttpErrors(false)\n    -\u003eauth(['user', 'passwd']);\n\n$query = $client-\u003equery(['foo' =\u003e 'bar'])-\u003egetJson('/get');\n\n$form = $client-\u003eformParams(['foo' =\u003e 'bar'])-\u003epostJson('/post');\n\n$json = $client-\u003ejson(['foo' =\u003e 'bar'])-\u003eputJson('/put');\n\n$download = $client-\u003esaveTo('image.png')-\u003eget('/image/png');\n\n$file = fopen('image.png', 'r');\n$uploadBody = $client-\u003ebody($file)-\u003epostJson('/post');\n\n$multipart = [\n    'foo' =\u003e 'bar',\n    'file' =\u003e $file,\n    'image' =\u003e [\n        'contents' =\u003e fopen('image.png', 'r'),\n        'filename' =\u003e 'filename.png',\n    ],\n];\n$formData = $client-\u003emultipart($multipart)-\u003epostJson('/post');\n```\n\n### Async Requests\n\n```php\n$promise = $client-\u003ejson($data)-\u003egetAsync('/get');\n\n$promise = $client-\u003eformParams($data)-\u003epostAsync('/post');\n```\n\n### Applying Request Options\n\nUsing the `option` method:\n\n```php\n$client\n    -\u003eoption('cert', $cert)\n    -\u003eoption([\n        'debug' =\u003e true,\n        'headers.Content-Type' =\u003e 'application/json',\n    ]);\n```\n\nOr using `camelCase` of any option name as a method on the client:\n\n```php\n$client\n    -\u003eallowRedirects(false)\n    -\u003etimeout(20)\n    -\u003ecookies($cookieJar)\n    -\u003eheaders([\n        'X-Foo' =\u003e 'foo',\n    ]);\n```\n\nIn addition, you may use `header`, `accept`, `acceptJson`, `userAgent` or `contentType` to set request headers:\n\n```php\n$client\n    -\u003eheader('X-Foo', 'foo');\n    -\u003eheader('X-Bar', 'bar');\n    -\u003eacceptJson()\n    -\u003econtentType('text/plain')\n    -\u003euserAgent('HttpClient/2.0')\n```\n\n### Global Default Request Options\n\nThe static `setDefaultOptions` method can be used to configure default options for every new client instance:\n\n```php\nHttpClient::setDefaultOptions([\n    'catch_exceptions' =\u003e true,\n    'http_errors' =\u003e false,\n    'connect_timeout' =\u003e 5,\n    'timeout' =\u003e 20,\n    'headers.User-Agent' =\u003e 'HttpClient/2.0',\n]);\n```\n\n### Catching Guzzle Exceptions\n\nThe `catchExceptions` method determines whether to catch Guzzle exceptions or not.\n\n```php\n$response = $client-\u003ecatchExceptions(true)-\u003eget('/api/path');\n\ntry {\n    $response = $client-\u003ecatchExceptions(false)-\u003eget('/api/path');\n} catch (Exception $e) {\n    // ...\n}\n```\n\n## Testing\n\n```sh\n$ composer test\n```\n\n## License\n\nThis package is open-sourced software licensed under the [MIT License](LICENSE.md).\n\n[request options]: http://docs.guzzlephp.org/en/stable/request-options.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felfsundae%2Fhttpclient","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felfsundae%2Fhttpclient","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felfsundae%2Fhttpclient/lists"}