{"id":18576110,"url":"https://github.com/thiagodp/httpwrapper","last_synced_at":"2025-05-16T00:34:43.893Z","repository":{"id":57040939,"uuid":"60320664","full_name":"thiagodp/httpwrapper","owner":"thiagodp","description":"A wrapper for the PSR-7's ResponseInterface.","archived":false,"fork":false,"pushed_at":"2018-02-12T23:58:49.000Z","size":7,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-19T16:35:00.843Z","etag":null,"topics":["builder","http","php","phputil","psr-7","wrapper"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thiagodp.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":"2016-06-03T05:29:27.000Z","updated_at":"2022-08-22T19:07:14.000Z","dependencies_parsed_at":"2022-08-24T01:10:38.806Z","dependency_job_id":null,"html_url":"https://github.com/thiagodp/httpwrapper","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thiagodp%2Fhttpwrapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thiagodp%2Fhttpwrapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thiagodp%2Fhttpwrapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thiagodp%2Fhttpwrapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thiagodp","download_url":"https://codeload.github.com/thiagodp/httpwrapper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254447880,"owners_count":22072755,"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":["builder","http","php","phputil","psr-7","wrapper"],"created_at":"2024-11-06T23:23:37.261Z","updated_at":"2025-05-16T00:34:43.855Z","avatar_url":"https://github.com/thiagodp.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# HTTP Wrapper\n\nThis library provides a wrapper for the \n[PSR-7](http://www.php-fig.org/psr/psr-7/)'s `ResponseInterface`.\n \nYou have to use it with a library/framework that offers\na [PSR-7](http://www.php-fig.org/psr/psr-7/) implementation,\nsuch as [Slim 3](http://www.slimframework.com/), \n[Guzzle](http://guzzlephp.org/), \n[Aura](https://github.com/auraphp/Aura.Router/tree/3.x#aurarouter) or \n[Zend](https://github.com/zendframework/zend-diactoros).\n\nWe use [semantic versioning](http://semver.org/). See our [releases](https://github.com/thiagodp/httpwrapper/releases).\n\nClasses:\n\n* [phputil\\HttpResponseWrapper](https://github.com/thiagodp/httpwrapper/blob/master/lib/HttpResponseWrapper.php)\n\nDependencies (installed automatically by `composer`):\n\n* [phputil/http](https://github.com/thiagodp/http)\n* [phputil/json](https://github.com/thiagodp/json)\n\n### Installation\n\n```command\ncomposer require phputil/httpwrapper\n```\n\n### Example 1\n\nUsing with Slim 3:\n\n```php\n\u003c?php\nrequire 'vendor/autoload.php';\n\nuse \\phputil\\HttpResponseWrapper;\nuse \\Slim\\App;\n\n$app = new App();\n$hrw = new HttpResponseWrapper();\n\n$app-\u003eget( '/names', function ( $request, $response, $args ) use ( $hrw ) {\n\n\t$names = array( 'Suzan', 'Mary', 'Mike', 'Bob' );\n\n\t// Will return HTTP 200 with the array as JSON encoded with UTF-8\n\treturn $hrw-\u003ewith( $response )\n\t\t-\u003ewithStatusOk()\n\t\t-\u003easJsonUtf8( $names ) // Any var type accepted\n\t\t-\u003eend()\n\t\t;\n} );\n\n$app-\u003eget( '/bad', function ( $request, $response, $args ) use ( $hrw ) {\n\t// Will return HTTP 400\n\treturn $hrw-\u003ewith( $response )-\u003ewithStatusBadRequest-\u003eend();\n} );\n\n$app-\u003eget( '/i-am-just-curious', function ( $request, $response, $args ) use ( $hrw ) {\n\t// Will return HTTP 403 (Forbidden)\n\treturn $hrw-\u003ewith( $response )-\u003ewithStatusForbidden-\u003eend();\n} );\n\n?\u003e\n```\n\n### Example 2\n\nAlso with Slim 3:\n\n```php\n\u003c?php\nrequire 'vendor/autoload.php';\n\nuse \\phputil\\HttpResponseWrapper;\nuse \\Slim\\App;\n\n$app = new App();\n$hrw = new HttpResponseWrapper();\n\n$app-\u003eget( '/names', function ( $request, $response, $args ) use ( $hrw ) {\n\n\t$names = array( 'Suzan', 'Mary', 'Mike', 'Bob' );\n\n\t// Helper method to return HTTP 200 with a JSON content encoded with UTF-8.\n\treturn $hrw-\u003ewith( $response )-\u003eok( $names );\n} );\n\n$app-\u003eget( '/bad', function ( $request, $response, $args ) use ( $hrw ) {\n\t// Helper method to return HTTP 400 with a JSON content encoded with UTF-8.\n\treturn $hrw-\u003ewith( $response )-\u003ebad( array( 'Something bad happened' ) );\n} );\n\n$app-\u003eget( '/none', function ( $request, $response, $args ) use ( $hrw ) {\n\t// Helper method to return HTTP 204.\n\treturn $hrw-\u003ewith( $response )-\u003enoContent();\n} );\n\n?\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthiagodp%2Fhttpwrapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthiagodp%2Fhttpwrapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthiagodp%2Fhttpwrapper/lists"}