{"id":40890257,"url":"https://github.com/moccalotto/hayttp","last_synced_at":"2026-01-22T01:46:35.754Z","repository":{"id":57018706,"uuid":"64228251","full_name":"moccalotto/hayttp","owner":"moccalotto","description":"HTTP request made easy!","archived":false,"fork":false,"pushed_at":"2019-01-24T07:17:23.000Z","size":234,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-13T06:21:58.375Z","etag":null,"topics":["api-client","decode-responses","http","http-client","json","php","xml"],"latest_commit_sha":null,"homepage":"https://moccalotto.github.io/docs/hayttp","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/moccalotto.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-07-26T14:32:14.000Z","updated_at":"2019-01-24T07:17:24.000Z","dependencies_parsed_at":"2022-08-22T20:30:52.409Z","dependency_job_id":null,"html_url":"https://github.com/moccalotto/hayttp","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"purl":"pkg:github/moccalotto/hayttp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moccalotto%2Fhayttp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moccalotto%2Fhayttp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moccalotto%2Fhayttp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moccalotto%2Fhayttp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/moccalotto","download_url":"https://codeload.github.com/moccalotto/hayttp/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moccalotto%2Fhayttp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28649944,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-22T01:17:37.254Z","status":"ssl_error","status_checked_at":"2026-01-22T01:17:35.564Z","response_time":86,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["api-client","decode-responses","http","http-client","json","php","xml"],"created_at":"2026-01-22T01:46:35.685Z","updated_at":"2026-01-22T01:46:35.739Z","avatar_url":"https://github.com/moccalotto.png","language":"PHP","readme":"# Hayttp\n[![Build Status](https://travis-ci.org/moccalotto/hayttp.svg?branch=master)](https://travis-ci.org/moccalotto/hayttp)\n\nHTTP request made easy!\n\n* Lightweight, fast and small footprint.\n* Syntacticly sweet, easy and intuitive.\n* Short-hands to the 7 RESTful HTTP methods.\n* Real file (and blob) uploads.\n* Basic Auth.\n* Immutable.\n* Awesome advanced options:\n  * Choose between CURL and php native http streams.\n  * Create your own http transport engine (for instance a guzzle wrapper).\n  * Choose ssl/tls scheme and version.\n  * Create custom payloads.\n\n## Installation\n\nTo add this package as a local, per-project dependency to your project, simply add a dependency on\n `moccalotto/hayttp` to your project's `composer.json` file like so:\n\n```json\n{\n    \"require\": {\n        \"moccalotto/hayttp\": \"~1.0\"\n    }\n}\n```\n\nAlternatively execute the following command in your shell.\n\n```bash\ncomposer require moccalotto/hayttp\n```\n\n## Usage\n\n```php\nuse Hayttp\\Hayttp;\n\n$response = Hayttp::get($url)-\u003esend();\n```\n\n### REST Methods\nHayttp is essentially a factory that can create and initialize `Request` objects.\nIt has methods for each of the 7 RESTful HTTP methods.\n\nMaking GET Requests:\n\n```php\n$response = Hayttp::get($url)-\u003esend();\n```\n\nA more interesting POST example.\n\n```php\n$response = Hayttp::post($url)\n    -\u003eacceptJson()\n    -\u003esendJson([\n        'this' =\u003e 'associative',\n        'array' =\u003e 'will',\n        'be' =\u003e 'converted',\n        'to' =\u003e 'a',\n        'json' =\u003e 'object',\n    ]);\n```\n\nA DELETE request that accept an XML body in the response.\n\n```php\n$response = Hayttp::delete($url)\n    -\u003eacceptXml()\n    -\u003esend();\n```\n\n\n### Decode responses\n\nYou can parse/unserialize the response payloads into native php data structures.\nHayttp currently supports json, xml and rfc3986.\n\nBelow is an example of how parse a response as json.\nJson objects are converted to `stdClass` objects, and json arrays are converted to php arrays:\n\n```php\n$stdClass = Hayttp::get($url)\n    -\u003eacceptJson()\n    -\u003esend()\n    -\u003ejsonDecoded();\n```\n\nHere is an example of a response decoded into a `SimpleXmlElement`:\n\n```php\n$simpleXmlElement = Hayttp::get($url)\n    -\u003eacceptXml()\n    -\u003esend()\n    -\u003exmlDecoded();\n```\n\nDecode a url-encoded string into an associative array:\n\n```php\n$array = Hayttp::get($url)\n    -\u003esend()\n    -\u003eurlDecoded();\n```\n\nDecode the respose, inferring the data type from the Content-Type header:\n\n```php\n$variable = Hayttp::get($url)-\u003esend()-\u003edecoded();\n```\n\n### Helper function\n\nYou can use the global `hayttp` method to access the default hayttp instance.\n\n```php\n$body = hayttp()-\u003ewithTimeout(10)\n    -\u003epost($url)\n    -\u003eensureJson()\n    -\u003esendJson(['foo' =\u003e 'bar',])\n    -\u003edecded();\n```\n\nYou can also use the `hayttp_*` method to make instant requests.\n\n```php\n// All the calls below are equivalent\n\n$response = hayttp_get($url);\n\n$response = Hayttp::get($url)\n                -\u003eensure2xx()\n                -\u003esend();\n\n$response = hayttp()-\u003eget($url)\n                -\u003eensure2xx()\n                -\u003esend();\n```\n\nHere are other examples of how to use the `hayttp_*` methods:\n\n```php\n// All the calls below are equivalent\n$xml = new SimpleXmlElement('\u003croot\u003e\u003cgroot\u003eBoot\u003c/groot\u003e\u003c/root\u003e');\n\n$response = hayttp_post($url, $xml);\n\n$response = Hayttp::post($url)\n                -\u003eensure2xx()\n                -\u003esendXml($xml);\n\n$response = hayttp()-\u003epost($url)\n                -\u003eensure2xx()\n                -\u003esendXml($xml);\n```\n\nPosting json\n\n```php\n// All the calls below are equivalent\n$data = ['foo' =\u003e ['bar' =\u003e ['baz']]];\n\n$response = hayttp_post($url, $data);\n\n$response = Hayttp::post($url)\n                -\u003eensure2xx()\n                -\u003esendJson($data);\n\n$response = hayttp()-\u003epost($url)\n                -\u003eensure2xx()\n                -\u003esendJson($data);\n```\n\nPutting raw text\n\n```php\n// All the calls below are equivalent\n$raw = file_get_contents($path);\n\n$response = hayttp_put($url, $raw);\n\n$response = Hayttp::put($url)\n                -\u003eensure2xx()\n                -\u003esendRaw($raw, 'application/octet-stream');\n\n$response = hayttp()-\u003eput($url)\n                -\u003eensure2xx()\n                -\u003esendRaw($raw, 'application/octet-stream');\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoccalotto%2Fhayttp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmoccalotto%2Fhayttp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoccalotto%2Fhayttp/lists"}