{"id":18794561,"url":"https://github.com/effectra/http-server-handler","last_synced_at":"2025-12-29T18:30:13.540Z","repository":{"id":167237794,"uuid":"641596497","full_name":"effectra/http-server-handler","owner":"effectra","description":"Handles an HTTP request by processing a stack of middlewares.","archived":false,"fork":false,"pushed_at":"2023-06-29T16:36:57.000Z","size":8,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2024-12-29T16:34:05.473Z","etag":null,"topics":["http","http-server","middleware","php","psr","server"],"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/effectra.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"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}},"created_at":"2023-05-16T20:04:08.000Z","updated_at":"2024-09-25T13:04:07.000Z","dependencies_parsed_at":null,"dependency_job_id":"7df37dd6-6d2c-4bb3-8881-dfb35afd9438","html_url":"https://github.com/effectra/http-server-handler","commit_stats":null,"previous_names":["effectra/http-server-handler"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/effectra%2Fhttp-server-handler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/effectra%2Fhttp-server-handler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/effectra%2Fhttp-server-handler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/effectra%2Fhttp-server-handler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/effectra","download_url":"https://codeload.github.com/effectra/http-server-handler/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239718702,"owners_count":19685798,"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-server","middleware","php","psr","server"],"created_at":"2024-11-07T21:29:47.296Z","updated_at":"2025-12-29T18:30:13.487Z","avatar_url":"https://github.com/effectra.png","language":"PHP","readme":"# Effectra RequestHandler\n\nThe `RequestHandler` class is designed to handle HTTP requests by processing a stack of middlewares. It implements the `RequestHandlerInterface` to ensure compatibility with standardized request handling protocols.\n\n## Installation\n\nYou can install the `RequestHandler` class using Composer. Run the following command:\n\n```\ncomposer require effectra/http-server-handler\n```\n\n## Usage\n\nTo use the `RequestHandler`, follow these steps:\n\n1. Create an instance of the `RequestHandler` class, providing a `ResponseInterface` object and an optional array of middlewares as parameters in the constructor.\n\n```php\nuse Effectra\\Http\\Server\\RequestHandler;\nuse Effectra\\Http\\Message\\Response;\n\n// Create a response object\n$response = new Response();\n\n// Create an array of middlewares\n$middlewares = [\n    new YourMiddleware(),\n    // Add more middlewares as needed\n];\n\n// Create an instance of RequestHandler\n$requestHandler = new RequestHandler($response, $middlewares);\n```\n\n2. Call the `handle` method of the `RequestHandler` class, passing a `ServerRequestInterface` object representing the incoming request.\n\n```php\nuse Psr\\Http\\Message\\ServerRequestInterface;\n\n// Create a ServerRequestInterface object representing the incoming request\n$request = ServerRequestInterface::fromGlobals();\n\n// Handle the request\n$response = $requestHandler-\u003ehandle($request);\n```\n\n3. The `handle` method will process the middlewares stack, executing each middleware in the order they were added. It will return a `ResponseInterface` object representing the response generated by the middlewares.\n\n```php\nuse Psr\\Http\\Message\\ResponseInterface;\n\n// Get the response generated by the middlewares stack\necho $response-\u003egetBody();\n```\n\n## Additional Methods\n\n### getLastRequest\n\nThe `RequestHandler` class provides a convenient method, `getLastRequest`, to retrieve the last processed request. It returns a `ServerRequestInterface|null` object representing the last request or `null` if no request has been processed.\n\n```php\nuse Psr\\Http\\Message\\ServerRequestInterface;\n\n// Retrieve the last processed request\n$lastRequest = $requestHandler-\u003egetLastRequest();\n\nif ($lastRequest instanceof ServerRequestInterface) {\n    // Process the last request\n} else {\n    // No request has been processed yet\n}\n```\n\n## Contributing\n\nContributions are welcome! If you would like to contribute to the development of the `RequestHandler` class, please follow these steps:\n\n1. Fork the repository and clone it locally.\n2. Create a new branch for your changes.\n3. Make your modifications and additions.\n4. Write tests to ensure the functionality of the class.\n5. Commit your changes and push them to your fork.\n6. Submit a pull request detailing your changes.\n\n## License\n\nThis project is licensed under the [MIT License](LICENSE).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feffectra%2Fhttp-server-handler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feffectra%2Fhttp-server-handler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feffectra%2Fhttp-server-handler/lists"}