{"id":23292821,"url":"https://github.com/lemmon/fetch-php","last_synced_at":"2025-08-22T00:32:52.129Z","repository":{"id":57013762,"uuid":"145855343","full_name":"lemmon/fetch-php","owner":"lemmon","description":"Tiny function, wrapped around Guzzle, PHP HTTP client. Inspired by Web API fetch() function.","archived":false,"fork":false,"pushed_at":"2019-11-22T16:27:31.000Z","size":5,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-04-24T14:29:18.995Z","etag":null,"topics":["curl","http","psr-7","webservices"],"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/lemmon.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":"2018-08-23T13:11:10.000Z","updated_at":"2024-02-14T10:02:58.000Z","dependencies_parsed_at":"2022-08-21T14:50:31.060Z","dependency_job_id":null,"html_url":"https://github.com/lemmon/fetch-php","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lemmon%2Ffetch-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lemmon%2Ffetch-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lemmon%2Ffetch-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lemmon%2Ffetch-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lemmon","download_url":"https://codeload.github.com/lemmon/fetch-php/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230542295,"owners_count":18242333,"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","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":["curl","http","psr-7","webservices"],"created_at":"2024-12-20T06:12:10.705Z","updated_at":"2024-12-20T06:12:11.131Z","avatar_url":"https://github.com/lemmon.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Fetch, simple PHP HTTP client\n=============================\n\nFetch is a tiny function, wrapped around Guzzle, PHP HTTP client. Inspired by Web API fetch() function.\n\n## Examples\n\n```php\n// plain GET request\n$res = fetch('http://uuid.lemmonjuice.com/');\n$body = $res-\u003ebody(); // returns response body\n// get JSON data\n$json = fetch('http://uuid.lemmonjuice.com/', [\n  'headers' =\u003e [\n    'Accept' =\u003e 'application/json',\n  ],\n])-\u003ejson();\n// POST data\n$res = fetch('http://httpbin.org/post', [\n  'method' =\u003e 'POST',\n  'headers' =\u003e [\n    'Content-Type' =\u003e 'application/json',\n    'Accept' =\u003e 'application/json',\n  ],\n  'json' =\u003e [\n    'hello' =\u003e 'world',\n  ],\n]);\n```\n\n## Installing Fetch\n\n```bash\ncomposer require lemmon/fetch\n```\n\n## API\n\n```php\nFetch\\Response fetch(string $resource, array $init = NULL)\n```\n\n### Parameters\n\n- `$resource` - a resource that you wish to fetch *(e.g. http://httpbin.org/post)*\n- `$init` (optional) - options array; see Guzzle's [Request Options](http://docs.guzzlephp.org/en/stable/request-options.html) documentation page for more info about available parameters; note: use additional parameter `method` to define request method; default method is GET\n\n### Response\n\n- `ok()` - (bool) has response been successful\n- `status()` - (int) status code\n- `statusText()` - (string) status text\n- `body()` - (string) response body\n- `json(bool $assoc = FALSE)` - JSON parsed response body\n- `psr()` - (GuzzleHttp\\Psr7\\Response) Guzzle's PSR-7 response (read more in Guzzle's [official documentation](http://docs.guzzlephp.org/en/stable/psr7.html#responses))\n\n## Read more\n\n- [Guzzle][Guzzle] - HTTP client that makes it easy to send HTTP requests and trivial to integrate with web services\n- [PSR-7][PSR7] - HTTP message interfaces\n- [fetch()][fetch] - Web API fetch()\n\n## License\n\n[MIT](https://tldrlegal.com/license/mit-license)\n\n[Guzzle]: https://github.com/guzzle/guzzle\n[PSR7]: https://www.php-fig.org/psr/psr-7/\n[fetch]: https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flemmon%2Ffetch-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flemmon%2Ffetch-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flemmon%2Ffetch-php/lists"}