{"id":19298168,"url":"https://github.com/shuchkin/react-http-client","last_synced_at":"2025-04-22T09:32:08.673Z","repository":{"id":57050081,"uuid":"162102321","full_name":"shuchkin/react-http-client","owner":"shuchkin","description":"ReactPHP async HTTP client, minimal dependencies","archived":false,"fork":false,"pushed_at":"2019-08-17T13:27:54.000Z","size":22,"stargazers_count":8,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-16T17:18:38.251Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/shuchkin.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-12-17T08:59:27.000Z","updated_at":"2024-07-18T17:45:49.000Z","dependencies_parsed_at":"2022-08-23T19:10:28.642Z","dependency_job_id":null,"html_url":"https://github.com/shuchkin/react-http-client","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shuchkin%2Freact-http-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shuchkin%2Freact-http-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shuchkin%2Freact-http-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shuchkin%2Freact-http-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shuchkin","download_url":"https://codeload.github.com/shuchkin/react-http-client/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249968747,"owners_count":21353408,"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":[],"created_at":"2024-11-09T23:07:09.587Z","updated_at":"2025-04-22T09:32:08.652Z","avatar_url":"https://github.com/shuchkin.png","language":"PHP","funding_links":["https://www.patreon.com/shuchkin"],"categories":[],"sub_categories":[],"readme":"# react-http-client 0.2\n[\u003cimg src=\"https://img.shields.io/endpoint.svg?url=https%3A%2F%2Fshieldsio-patreon.herokuapp.com%2Fshuchkin\" /\u003e](https://www.patreon.com/shuchkin)\n\nReactPHP async HTTP client, minimal dependencies:\nhttps://reactphp.org/\n\n## Basic Usage\n```php\n$loop = \\React\\EventLoop\\Factory::create();\n$http = new \\Shuchkin\\ReactHTTP\\Client( $loop );\n\n$http-\u003eget( 'http://api.ipify.org' )-\u003ethen(\n\tfunction( $content ) {\n\t\techo $content; // 123.45.67.8\n\t}\n);\n\n$loop-\u003erun();\n```\n\n## Post\n```php\n$loop = \\React\\EventLoop\\Factory::create();\n\n$http = new \\Shuchkin\\ReactHTTP\\Client( $loop );\n\n$http-\u003epost( 'https://reqres.in/api/users', '{\"name\": \"morpheus\",\"job\": \"leader\"}' )-\u003ethen(\n\tfunction ( $content ) {\n\t\techo $content;\n\t},\n\tfunction ( \\Exception $ex ) {\n\t\techo 'HTTP error '.$ex-\u003egetCode().' '.$ex-\u003egetMessage();\n\t}\n);\n\n$loop-\u003erun();\n\n// {\"name\":\"morpheus\",\"job\":\"leader\",\"id\":\"554\",\"createdAt\":\"2018-12-17T10:31:29.469Z\"}\n```\n\n## Send headers\n```php\n$loop = \\React\\EventLoop\\Factory::create();\n$http = new \\Shuchkin\\ReactHTTP\\Client( $loop );\n\n$http-\u003eget('https://jigsaw.w3.org/HTTP/TE/foo.txt',['User-Agent' =\u003e 'ReactPHP Awesome'] )-\u003ethen(\n\tfunction ( $content ) {\n\t\techo $content;\n\t},\n\tfunction ( \\Exception $ex ) {\n\t\techo 'HTTP error '.$ex-\u003egetCode().' '.$ex-\u003egetMessage();\n\t}\n);\n$loop-\u003erun();\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n```\n\n## Read chunks\n```php\n$loop = \\React\\EventLoop\\Factory::create();\n\n$http = new \\Shuchkin\\ReactHTTP\\Client( $loop );\n$http-\u003eget( 'https://jigsaw.w3.org/HTTP/ChunkedScript' )-\u003ethen(\n\tfunction () {\n\t\techo PHP_EOL . 'Mission complete';\n\t},\n\tfunction ( \\Exception $ex ) {\n\t\techo 'ERROR '.$ex-\u003egetCode().' '.$ex-\u003egetMessage();\n\t}\n);\n\n$http-\u003eon('chunk', function( $chunk ) {\n\techo PHP_EOL.'-- CHUNK='.$chunk;\n});\n\n$loop-\u003erun();\n```\n\n## Get headers \u0026 debug\n```php\n$loop = \\React\\EventLoop\\Factory::create();\n\n$http = new \\Shuchkin\\ReactHTTP\\Client( $loop );\n\n$http-\u003erequest('GET','https://reqres.in/api/users')-\u003ethen(\n\tfunction( \\Shuchkin\\ReactHTTP\\Client $client ) {\n\t\t// dump response headers\n\t\tprint_r( $client-\u003eheaders );\n\t\t// dump content\n\t\techo PHP_EOL . $client-\u003econtent;\n\t},\n\tfunction ( \\Exception $ex ) {\n\t\techo 'ERROR '.$ex-\u003egetCode().' '.$ex-\u003egetMessage();\n\t}\n);\n// enable debug mode\n$http-\u003eon('debug', function( $s ) { echo trim($s).PHP_EOL; } );\n$loop-\u003erun();\n```\n\n## Install\n\nThe recommended way to install this library is [through Composer](https://getcomposer.org).\n[New to Composer?](https://getcomposer.org/doc/00-intro.md)\n\nThis will install the latest supported version:\n\n```bash\n$ composer require shuchkin/react-http-client\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshuchkin%2Freact-http-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshuchkin%2Freact-http-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshuchkin%2Freact-http-client/lists"}