{"id":18794564,"url":"https://github.com/effectra/http-message","last_synced_at":"2025-12-29T18:30:13.899Z","repository":{"id":167731460,"uuid":"643343069","full_name":"effectra/http-message","owner":"effectra","description":"Effectra/Http-Message: A PHP library implementing PSR-7 for standardized handling of HTTP requests and responses.","archived":false,"fork":false,"pushed_at":"2024-01-06T20:47:03.000Z","size":17,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2024-12-29T16:34:07.044Z","etag":null,"topics":["http","http-message","php","psr","psr-7","request","response","server-request","stream","upload-file","uri"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/effectra.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2023-05-20T21:20:21.000Z","updated_at":"2023-05-20T22:49:10.000Z","dependencies_parsed_at":"2024-11-07T21:32:13.837Z","dependency_job_id":"4338d374-d643-49e0-8320-73cc75db9e63","html_url":"https://github.com/effectra/http-message","commit_stats":null,"previous_names":["effectra/http-message"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/effectra%2Fhttp-message","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/effectra%2Fhttp-message/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/effectra%2Fhttp-message/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/effectra%2Fhttp-message/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/effectra","download_url":"https://codeload.github.com/effectra/http-message/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239718733,"owners_count":19685806,"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":["http","http-message","php","psr","psr-7","request","response","server-request","stream","upload-file","uri"],"created_at":"2024-11-07T21:29:48.058Z","updated_at":"2025-12-29T18:30:13.869Z","avatar_url":"https://github.com/effectra.png","language":"PHP","readme":"# Effectra HTTP Message Library\n\nA lightweight PHP library for working with HTTP messages.\n\n## Installation\n\nInstall the library using Composer:\n\n```bash\ncomposer require effectra/http-message\n```\n\n## Usage\n\n### Creating a Request\n\n```php\nuse Effectra\\Http\\Message\\Request;\nuse Effectra\\Http\\Message\\Uri;\nuse Effectra\\Http\\Message\\Stream;\n\n// Create a request\n$uri = new Uri('https://api.example.com/users');\n$body = new Stream(json_encode(['name' =\u003e 'John Doe']));\n\n$request = new Request('POST', $uri, [], $body);\n\n// Get request information\necho $request-\u003egetMethod(); // Output: POST\necho $request-\u003egetUri(); // Output: https://api.example.com/users\necho $request-\u003egetBody()-\u003egetContents(); // Output: {\"name\":\"John Doe\"}\n```\n\n### Creating a Response\n\n```php\nuse Effectra\\Http\\Message\\Response;\nuse Effectra\\Http\\Message\\Stream;\n\n// Create a response\n$body = new Stream('Hello, world!');\n\n$response = new Response(200, [], $body);\n\n// Get response information\necho $response-\u003egetStatusCode(); // Output: 200\necho $response-\u003egetReasonPhrase(); // Output: OK\necho $response-\u003egetBody()-\u003egetContents(); // Output: Hello, world!\n```\n\n### Creating a Stream\n\n```php\nuse Effectra\\Http\\Message\\Stream;\n\n// Create a stream from a string\n$stream = new Stream('Hello, world!');\n\n// Read from the stream\necho $stream-\u003egetContents(); // Output: Hello, world!\n\n// Write to the stream\n$stream-\u003ewrite('Goodbye!');\necho $stream-\u003egetContents(); // Output: Goodbye!\n```\n\n### Working with Uploaded Files\n\n```php\nuse Effectra\\Http\\Message\\UploadedFile;\n\n// Create an uploaded file instance\n$file = $_FILES['my_file'];\n\n$uploadedFile = new UploadedFile(\n    $file['tmp_name'],\n    $file['size'],\n    $file['error'],\n    $file['name'],\n    $file['type']\n);\n\n// Get information about the uploaded file\necho $uploadedFile-\u003egetClientFilename(); // Output: my_file.txt\necho $uploadedFile-\u003egetClientMediaType(); // Output: text/plain\n\n// Move the uploaded file to a target location\n$targetPath = '/path/to/destination';\n$uploadedFile-\u003emoveTo($targetPath);\n```\n\n### Working with URIs\n\n```php\nuse Effectra\\Http\\Message\\Uri;\n\n// Create a URI instance\n$uri = new Uri('https://example.com/path?query=param#fragment');\n\n// Get individual URI components\necho $uri-\u003egetScheme(); // Output: https\necho $uri-\u003egetHost(); // Output: example.com\necho $uri-\u003egetPath(); // Output: /path\necho $uri-\u003egetQuery(); // Output: query=param\necho $uri-\u003egetFragment(); // Output: fragment\n\n// Modify the URI components\n$modifiedUri = $uri\n    -\u003ewithScheme('http')\n    -\u003ewithHost('example.org')\n    -\u003ewithPath('/new-path')\n    -\u003ewithQuery('key=value')\n    -\u003ewithFragment('new-fragment');\n\necho $modifiedUri; // Output: http://example.org/new-path?key=value#new-fragment\n```\n\n## Contributing\n\nContributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request on GitHub.\n\n## License\n\nThis library is released under the MIT License. See [LICENSE](LICENSE) for more information.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feffectra%2Fhttp-message","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feffectra%2Fhttp-message","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feffectra%2Fhttp-message/lists"}