{"id":13609334,"url":"https://github.com/Nyholm/psr7","last_synced_at":"2025-04-12T20:31:41.584Z","repository":{"id":37706148,"uuid":"63238907","full_name":"Nyholm/psr7","owner":"Nyholm","description":"A super lightweight PSR-7 implementation","archived":false,"fork":false,"pushed_at":"2024-09-09T07:07:02.000Z","size":281,"stargazers_count":1216,"open_issues_count":5,"forks_count":74,"subscribers_count":26,"default_branch":"master","last_synced_at":"2025-04-11T07:34:44.086Z","etag":null,"topics":["psr-17","psr-7"],"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/Nyholm.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":["nyholm","Zegnat"]}},"created_at":"2016-07-13T10:59:54.000Z","updated_at":"2025-04-03T21:24:57.000Z","dependencies_parsed_at":"2024-04-12T08:43:06.087Z","dependency_job_id":"c068dbe4-5f93-4561-b35d-b4609a007ebe","html_url":"https://github.com/Nyholm/psr7","commit_stats":{"total_commits":188,"total_committers":30,"mean_commits":6.266666666666667,"dds":0.3829787234042553,"last_synced_commit":"7f77c0eaefdb849630df611ba2204ce92dfe5ef5"},"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nyholm%2Fpsr7","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nyholm%2Fpsr7/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nyholm%2Fpsr7/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nyholm%2Fpsr7/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Nyholm","download_url":"https://codeload.github.com/Nyholm/psr7/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248629610,"owners_count":21136281,"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":["psr-17","psr-7"],"created_at":"2024-08-01T19:01:34.190Z","updated_at":"2025-04-12T20:31:41.338Z","avatar_url":"https://github.com/Nyholm.png","language":"PHP","funding_links":["https://github.com/sponsors/nyholm","https://github.com/sponsors/Zegnat"],"categories":["Table of Contents","PHP","目录","Packages"],"sub_categories":["HTTP","HTTP客户端 HTTP Client","PSR-7 implementations","Globalization"],"readme":"# PSR-7 implementation\n\n[![Latest Version](https://img.shields.io/github/release/Nyholm/psr7.svg?style=flat-square)](https://github.com/Nyholm/psr7/releases)\n[![Total Downloads](https://poser.pugx.org/nyholm/psr7/downloads)](https://packagist.org/packages/nyholm/psr7)\n[![Monthly Downloads](https://poser.pugx.org/nyholm/psr7/d/monthly.png)](https://packagist.org/packages/nyholm/psr7)\n[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE)\n[![Static analysis](https://github.com/Nyholm/psr7/actions/workflows/static.yml/badge.svg?branch=master)](https://github.com/Nyholm/psr7/actions/workflows/static.yml?query=branch%3Amaster)\n[![Tests](https://github.com/Nyholm/psr7/actions/workflows/tests.yml/badge.svg?branch=master)](https://github.com/Nyholm/psr7/actions/workflows/tests.yml?query=branch%3Amaster)\n\nA super lightweight PSR-7 implementation. Very strict and very fast.\n\n| Description | Guzzle | Laminas | Slim | Nyholm |\n| ---- | ------ | ---- | ---- | ------ |\n| Lines of code | 3.300 | 3.100 | 1.900 | 1.000 |\n| PSR-7* | 66% | 100% | 75% | 100% |\n| PSR-17 | No | Yes | Yes | Yes |\n| HTTPlug | No | No | No | Yes |\n| Performance (runs per second)** | 14.553 | 14.703 | 13.416 | 17.734 |\n\n\\* Percent of completed tests in https://github.com/php-http/psr7-integration-tests\n\n\\** Benchmark with 50.000 runs. See https://github.com/devanych/psr-http-benchmark (higher is better)\n\n## Installation\n\n```bash\ncomposer require nyholm/psr7\n```\n\nIf you are using Symfony Flex then you get all message factories registered as services.\n\n## Usage\n\nThe PSR-7 objects do not contain any other public methods than those defined in\nthe [PSR-7 specification](https://www.php-fig.org/psr/psr-7/).\n\n### Create objects\n\nUse the PSR-17 factory to create requests, streams, URIs etc.\n\n```php\n$psr17Factory = new \\Nyholm\\Psr7\\Factory\\Psr17Factory();\n$request = $psr17Factory-\u003ecreateRequest('GET', 'http://tnyholm.se');\n$stream = $psr17Factory-\u003ecreateStream('foobar');\n```\n\n### Sending a request\n\nWith [HTTPlug](http://httplug.io/) or any other PSR-18 (HTTP client) you may send\nrequests like:\n\n```bash\ncomposer require kriswallsmith/buzz\n```\n\n```php\n$psr17Factory = new \\Nyholm\\Psr7\\Factory\\Psr17Factory();\n$psr18Client = new \\Buzz\\Client\\Curl($psr17Factory);\n\n$request = $psr17Factory-\u003ecreateRequest('GET', 'http://tnyholm.se');\n$response = $psr18Client-\u003esendRequest($request);\n```\n\n### Create server requests\n\nThe [`nyholm/psr7-server`](https://github.com/Nyholm/psr7-server) package can be used\nto create server requests from PHP superglobals.\n\n```bash\ncomposer require nyholm/psr7-server\n```\n\n```php\n$psr17Factory = new \\Nyholm\\Psr7\\Factory\\Psr17Factory();\n\n$creator = new \\Nyholm\\Psr7Server\\ServerRequestCreator(\n    $psr17Factory, // ServerRequestFactory\n    $psr17Factory, // UriFactory\n    $psr17Factory, // UploadedFileFactory\n    $psr17Factory  // StreamFactory\n);\n\n$serverRequest = $creator-\u003efromGlobals();\n```\n\n### Emitting a response\n\n```bash\ncomposer require laminas/laminas-httphandlerrunner\n```\n\n```php\n$psr17Factory = new \\Nyholm\\Psr7\\Factory\\Psr17Factory();\n\n$responseBody = $psr17Factory-\u003ecreateStream('Hello world');\n$response = $psr17Factory-\u003ecreateResponse(200)-\u003ewithBody($responseBody);\n(new \\Laminas\\HttpHandlerRunner\\Emitter\\SapiEmitter())-\u003eemit($response);\n```\n\n## Our goal\n\nThis package is currently maintained by [Tobias Nyholm](http://nyholm.se) and\n[Martijn van der Ven](https://vanderven.se/martijn/). They have decided that the\ngoal of this library should be to provide a super strict implementation of\n[PSR-7](https://www.php-fig.org/psr/psr-7/) that is blazing fast.\n\nThe package will never include any extra features nor helper methods. All our classes\nand functions exist because they are required to fulfill the PSR-7 specification.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FNyholm%2Fpsr7","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FNyholm%2Fpsr7","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FNyholm%2Fpsr7/lists"}