{"id":24694476,"url":"https://github.com/roadrunner-php/http","last_synced_at":"2025-10-09T01:31:09.764Z","repository":{"id":43040413,"uuid":"307346165","full_name":"roadrunner-php/http","owner":"roadrunner-php","description":"🔌 PSR7 Worker Client for RoadRunner application server.","archived":false,"fork":false,"pushed_at":"2025-08-31T12:43:11.000Z","size":130,"stargazers_count":61,"open_issues_count":0,"forks_count":7,"subscribers_count":8,"default_branch":"3.x","last_synced_at":"2025-09-21T22:09:56.266Z","etag":null,"topics":["hacktoberfest","http","php","psr-17","psr-7","roadrunner"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":false,"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/roadrunner-php.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"roadrunner-server"}},"created_at":"2020-10-26T11:11:30.000Z","updated_at":"2025-09-19T22:10:23.000Z","dependencies_parsed_at":"2023-01-21T14:17:58.113Z","dependency_job_id":"532dffc4-beb4-4efb-a47b-2e2c8842dd42","html_url":"https://github.com/roadrunner-php/http","commit_stats":null,"previous_names":["spiral/roadrunner-http"],"tags_count":20,"template":false,"template_full_name":null,"purl":"pkg:github/roadrunner-php/http","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roadrunner-php%2Fhttp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roadrunner-php%2Fhttp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roadrunner-php%2Fhttp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roadrunner-php%2Fhttp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/roadrunner-php","download_url":"https://codeload.github.com/roadrunner-php/http/tar.gz/refs/heads/3.x","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roadrunner-php%2Fhttp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279000725,"owners_count":26082895,"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-10-08T02:00:06.501Z","response_time":56,"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":["hacktoberfest","http","php","psr-17","psr-7","roadrunner"],"created_at":"2025-01-26T23:59:51.053Z","updated_at":"2025-10-09T01:31:09.472Z","avatar_url":"https://github.com/roadrunner-php.png","language":"PHP","readme":"\u003ca href=\"https://roadrunner.dev\" target=\"_blank\"\u003e\n  \u003cpicture\u003e\n    \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://github.com/roadrunner-server/.github/assets/8040338/e6bde856-4ec6-4a52-bd5b-bfe78736c1ff\"\u003e\n    \u003cimg align=\"center\" src=\"https://github.com/roadrunner-server/.github/assets/8040338/040fb694-1dd3-4865-9d29-8e0748c2c8b8\"\u003e\n  \u003c/picture\u003e\n\u003c/a\u003e\n\u003cp align=\"center\"\u003e\n \u003ca href=\"https://packagist.org/packages/spiral/roadrunner\"\u003e\u003cimg src=\"https://poser.pugx.org/spiral/roadrunner/version\"\u003e\u003c/a\u003e\n\t\u003ca href=\"https://pkg.go.dev/github.com/spiral/roadrunner?tab=doc\"\u003e\u003cimg src=\"https://godoc.org/github.com/spiral/roadrunner?status.svg\"\u003e\u003c/a\u003e\n\t\u003ca href=\"https://github.com/spiral/roadrunner/actions\"\u003e\u003cimg src=\"https://github.com/spiral/roadrunner/workflows/CI/badge.svg\" alt=\"\"\u003e\u003c/a\u003e\n\t\u003ca href=\"https://goreportcard.com/report/github.com/spiral/roadrunner\"\u003e\u003cimg src=\"https://goreportcard.com/badge/github.com/spiral/roadrunner\"\u003e\u003c/a\u003e\n\t\u003ca href=\"https://scrutinizer-ci.com/g/spiral/roadrunner/?branch=master\"\u003e\u003cimg src=\"https://scrutinizer-ci.com/g/spiral/roadrunner/badges/quality-score.png\"\u003e\u003c/a\u003e\n\t\u003ca href=\"https://discord.gg/spiralphp\"\u003e\u003cimg src=\"https://img.shields.io/badge/discord-chat-magenta.svg\"\u003e\u003c/a\u003e\n\t\u003ca href=\"https://packagist.org/packages/spiral/roadrunner\"\u003e\u003cimg src=\"https://img.shields.io/packagist/dd/spiral/roadrunner?style=flat-square\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\nRoadRunner is an open-source (MIT licensed) high-performance PHP application server, load balancer, and process manager.\nIt supports running as a service with the ability to extend its functionality on a per-project basis.\n\nRoadRunner includes PSR-7/PSR-17 compatible HTTP and HTTP/2 server and can be used to replace classic Nginx+FPM setup\nwith much greater performance and flexibility.\n\n\u003cp align=\"center\"\u003e\n\t\u003ca href=\"https://roadrunner.dev/\"\u003e\u003cb\u003eOfficial Website\u003c/b\u003e\u003c/a\u003e | \n\t\u003ca href=\"https://docs.roadrunner.dev\"\u003e\u003cb\u003eDocumentation\u003c/b\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\n## Repository:\n\nThis repository contains the codebase PSR-7 PHP workers.\nCheck [spiral/roadrunner](https://github.com/spiral/roadrunner) to get application server.\n\n## Requirements:\n\nEnsure that your server is configured with the following PHP versions and extensions:\n\n- PHP \u003e=8.1\n- ext-protobuf: This extension is optional but **highly recommended for installation**.\n  Without it, performance may be up to 50% lower.\n- RoadRunner ^2023.3\n\n## Installation:\n\nTo install application server and HTTP codebase:\n\n```bash\ncomposer require spiral/roadrunner-http nyholm/psr7\n```\n\nYou can use the convenient installer to download the latest available compatible version of RoadRunner assembly:\n\n```bash\ncomposer require spiral/roadrunner-cli --dev\n```\n\nTo download latest version of application server:\n\n```bash\nvendor/bin/rr get\n```\n\n\u003e You can use any [PSR-17 compatible implementation](https://packagist.org/providers/psr/http-factory-implementation).\n\n\n## Example:\n\nTo init abstract RoadRunner worker:\n\n```php\n\u003c?php\n\nrequire __DIR__ . '/vendor/autoload.php';\n\nuse Nyholm\\Psr7\\Response;\nuse Nyholm\\Psr7\\Factory\\Psr17Factory;\n\nuse Spiral\\RoadRunner\\Worker;\nuse Spiral\\RoadRunner\\Http\\PSR7Worker;\n\n\n// Create new RoadRunner worker from global environment\n$worker = Worker::create();\n\n// Create common PSR-17 HTTP factory\n$factory = new Psr17Factory();\n\n//\n// Create PSR-7 worker and pass:\n//  - RoadRunner worker\n//  - PSR-17 ServerRequestFactory\n//  - PSR-17 StreamFactory\n//  - PSR-17 UploadFilesFactory\n//\n$psr7 = new PSR7Worker($worker, $factory, $factory, $factory);\n\nwhile (true) {\n    try {\n        $request = $psr7-\u003ewaitRequest();\n    } catch (\\Throwable $e) {\n        // Although the PSR-17 specification clearly states that there can be\n        // no exceptions when creating a request, however, some implementations\n        // may violate this rule. Therefore, it is recommended to process the \n        // incoming request for errors.\n        //\n        // Send \"Bad Request\" response.\n        $psr7-\u003erespond(new Response(400));\n        continue;\n    }\n\n    try {\n        // Here is where the call to your application code will be located. \n        // For example:\n        //\n        //  $response = $app-\u003esend($request);\n        //\n        // Reply by the 200 OK response\n        $psr7-\u003erespond(new Response(200, [], 'Hello RoadRunner!'));\n    } catch (\\Throwable $e) {\n        // In case of any exceptions in the application code, you should handle\n        // them and inform the client about the presence of a server error.\n        //\n        // Reply by the 500 Internal Server Error response\n        $psr7-\u003erespond(new Response(500, [], 'Something Went Wrong!'));\n\n        // Additionally, we can inform the RoadRunner that the processing \n        // of the request failed.\n        $worker-\u003eerror((string)$e);\n    }\n}\n```\n\n### Stream response\n\nTo send a response in a stream, set the `$chunkSize` property in `PSR7Worker`:\n\n```php\n$psr7 = new PSR7Worker($worker, $factory, $factory, $factory);\n$psr7-\u003echunkSize = 512 * 1024; // 512KB\n```\n\nNow PSR7Worker will cut the response into chunks of 512KB and send them to the stream.\n\n### Early hints\n\nTo send multiple responses you may use the `\\Spiral\\RoadRunner\\Http\\HttpWorker::respond()` method with\nthe `endOfStream` parameter set to `false`. This will send the response to the client and allow you to send\nadditional responses.\n\n```php\n/** @var \\Spiral\\RoadRunner\\Http\\PSR7Worker $psr7 */\n$httpWorker = $psr7-\u003egetHttpWorker()\n    -\u003erespond(103, header: ['Link' =\u003e ['\u003c/style.css\u003e; rel=preload; as=style']], endOfStream: false);\n\n// End of stream will be sent automatically after PSR7Worker::respond() call\n$psr7-\u003erespond(new Response(200, [], 'Hello RoadRunner!'));\n```\n\n\n[![try Spiral Framework](https://user-images.githubusercontent.com/773481/220979012-e67b74b5-3db1-41b7-bdb0-8a042587dedc.jpg)](https://spiral.dev/)\n\n## Testing:\n\nThis codebase is automatically tested via host repository - [spiral/roadrunner](https://github.com/roadrunner-server/roadrunner).\n\n\n## License:\n\nThe MIT License (MIT). Please see [`LICENSE`](./LICENSE) for more information. Maintained\nby [Spiral Scout](https://spiralscout.com).\n","funding_links":["https://github.com/sponsors/roadrunner-server"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froadrunner-php%2Fhttp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Froadrunner-php%2Fhttp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froadrunner-php%2Fhttp/lists"}