{"id":29017854,"url":"https://github.com/cakephp/http","last_synced_at":"2025-08-03T20:34:34.210Z","repository":{"id":62499057,"uuid":"214704724","full_name":"cakephp/http","owner":"cakephp","description":"[READONLY] HTTP client and server libraries ","archived":false,"fork":false,"pushed_at":"2025-06-21T03:36:41.000Z","size":1437,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":5,"default_branch":"4.x","last_synced_at":"2025-06-21T04:29:09.298Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cakephp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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}},"created_at":"2019-10-12T19:38:18.000Z","updated_at":"2025-01-05T03:45:42.000Z","dependencies_parsed_at":"2023-02-06T10:15:45.627Z","dependency_job_id":"470d67eb-5289-40b0-8bd8-65754dae189d","html_url":"https://github.com/cakephp/http","commit_stats":{"total_commits":1158,"total_committers":89,"mean_commits":13.01123595505618,"dds":0.6692573402417963,"last_synced_commit":"7ae34b9e6a4b2022014bbc035864392b11979ca2"},"previous_names":[],"tags_count":118,"template":false,"template_full_name":null,"purl":"pkg:github/cakephp/http","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cakephp%2Fhttp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cakephp%2Fhttp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cakephp%2Fhttp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cakephp%2Fhttp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cakephp","download_url":"https://codeload.github.com/cakephp/http/tar.gz/refs/heads/4.x","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cakephp%2Fhttp/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261967132,"owners_count":23237663,"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":[],"created_at":"2025-06-25T23:07:16.003Z","updated_at":"2025-06-25T23:07:16.903Z","avatar_url":"https://github.com/cakephp.png","language":"PHP","readme":"[![Total Downloads](https://img.shields.io/packagist/dt/cakephp/http.svg?style=flat-square)](https://packagist.org/packages/cakephp/http)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](LICENSE.txt)\n\n# CakePHP Http Library\n\nThis library provides a PSR-15 Http middleware server, PSR-7 Request and\nResponse objects, and a PSR-18 Http Client. Together these classes let you\nhandle incoming server requests and send outgoing HTTP requests.\n\n## Using the Http Client\n\nSending requests is straight forward. Doing a GET request looks like:\n\n```php\nuse Cake\\Http\\Client;\n\n$http = new Client();\n\n// Simple get\n$response = $http-\u003eget('http://example.com/test.html');\n\n// Simple get with querystring\n$response = $http-\u003eget('http://example.com/search', ['q' =\u003e 'widget']);\n\n// Simple get with querystring \u0026 additional headers\n$response = $http-\u003eget('http://example.com/search', ['q' =\u003e 'widget'], [\n  'headers' =\u003e ['X-Requested-With' =\u003e 'XMLHttpRequest'],\n]);\n```\n\nTo learn more read the [Http Client documentation](https://book.cakephp.org/4/en/core-libraries/httpclient.html).\n\n## Using the Http Server\n\nThe Http Server allows an `HttpApplicationInterface` to process requests and\nemit responses. To get started first implement the\n`Cake\\Http\\HttpApplicationInterface`  A minimal example could look like:\n\n```php\nnamespace App;\n\nuse Cake\\Core\\HttpApplicationInterface;\nuse Cake\\Http\\MiddlewareQueue;\nuse Cake\\Http\\Response;\nuse Psr\\Http\\Message\\ResponseInterface;\nuse Psr\\Http\\Message\\ServerRequestInterface;\n\nclass Application implements HttpApplicationInterface\n{\n    /**\n     * Load all the application configuration and bootstrap logic.\n     *\n     * @return void\n     */\n    public function bootstrap(): void\n    {\n        // Load configuration here. This is the first\n        // method Cake\\Http\\Server will call on your application.\n    }\n\n    /**\n     * Define the HTTP middleware layers for an application.\n     *\n     * @param \\Cake\\Http\\MiddlewareQueue $middlewareQueue The middleware queue to set in your App Class\n     * @return \\Cake\\Http\\MiddlewareQueue\n     */\n    public function middleware(MiddlewareQueue $middlewareQueue): MiddlewareQueue\n    {\n        // Add middleware for your application.\n        return $middlewareQueue;\n    }\n\n    /**\n     * Handle incoming server request and return a response.\n     *\n     * @param \\Psr\\Http\\Message\\ServerRequestInterface $request The request\n     * @return \\Psr\\Http\\Message\\ResponseInterface\n     */\n    public function handle(ServerRequestInterface $request): ResponseInterface\n    {\n        return new Response(['body'=\u003e'Hello World!']);\n    }\n}\n```\n\nOnce you have an application with some middleware. You can start accepting\nrequests. In your application's webroot, you can add an `index.php` and process\nrequests:\n\n```php\n\u003c?php\n// in webroot/index.php\nrequire dirname(__DIR__) . '/vendor/autoload.php';\n\nuse App\\Application;\nuse Cake\\Http\\Server;\n\n// Bind your application to the server.\n$server = new Server(new Application());\n\n// Run the request/response through the application and emit the response.\n$server-\u003eemit($server-\u003erun());\n```\n\nYou can then run your application using PHP's built in webserver:\n\n```bash\nphp -S localhost:8765 -t ./webroot ./webroot/index.php\n```\n\nFor more information on middleware, [consult the\ndocumentation](https://book.cakephp.org/4/en/controllers/middleware.html)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcakephp%2Fhttp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcakephp%2Fhttp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcakephp%2Fhttp/lists"}