{"id":19745634,"url":"https://github.com/elementaryframework/waterpipe","last_synced_at":"2025-04-30T07:34:37.718Z","repository":{"id":56976416,"uuid":"135860490","full_name":"ElementaryFramework/WaterPipe","owner":"ElementaryFramework","description":"URL routing framework, requests/responses handler, and HTTP client for PHP","archived":false,"fork":false,"pushed_at":"2021-05-02T11:36:36.000Z","size":195,"stargazers_count":25,"open_issues_count":1,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-12T02:10:23.694Z","etag":null,"topics":["composer","http","http-client","php","php7","request","response","responses-handler","url-rewrite","url-router"],"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/ElementaryFramework.png","metadata":{"files":{"readme":"README.md","changelog":null,"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},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":["https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=AGAQAC3W4ZRMA\u0026source=url"]}},"created_at":"2018-06-03T00:00:16.000Z","updated_at":"2024-02-14T10:38:29.000Z","dependencies_parsed_at":"2022-08-21T08:10:58.106Z","dependency_job_id":null,"html_url":"https://github.com/ElementaryFramework/WaterPipe","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ElementaryFramework%2FWaterPipe","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ElementaryFramework%2FWaterPipe/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ElementaryFramework%2FWaterPipe/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ElementaryFramework%2FWaterPipe/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ElementaryFramework","download_url":"https://codeload.github.com/ElementaryFramework/WaterPipe/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224202851,"owners_count":17272807,"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":["composer","http","http-client","php","php7","request","response","responses-handler","url-rewrite","url-router"],"created_at":"2024-11-12T02:10:36.537Z","updated_at":"2024-11-12T02:10:37.246Z","avatar_url":"https://github.com/ElementaryFramework.png","language":"PHP","funding_links":["https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=AGAQAC3W4ZRMA\u0026source=url"],"categories":[],"sub_categories":[],"readme":"\u003ccenter\u003e\n\n![WaterPipe Logo](assets/banner.png)\n\n\u003c/center\u003e\n\n# WaterPipe\n\n[![downloads](https://img.shields.io/packagist/dt/elementaryframework/water-pipe?style=for-the-badge\u0026logo=packagist)](https://packagist.org/packages/elementaryframework/water-pipe)\n[![downloads](https://img.shields.io/packagist/v/elementaryframework/water-pipe?style=for-the-badge\u0026logo=packagist)](https://packagist.org/packages/elementaryframework/water-pipe)\n[![downloads](https://img.shields.io/github/repo-size/ElementaryFramework/WaterPipe?style=for-the-badge\u0026logo=github)](https://github.com/ElementaryFramework/WaterPipe)\n[![downloads](https://img.shields.io/github/license/ElementaryFramework/WaterPipe?style=for-the-badge\u0026logo=github)](https://github.com/ElementaryFramework/WaterPipe/blob/master/LICENSE)\n\nA powerful routing framework and requests/responses handler for PHP\n\nWaterPipe is a library which allows you to easily handle HTTP requests and responses with PHP, giving you all the power\nto build a fully RESTful API, to create a routing framework for your web application, etc...\n\n## Example\n\n```php\n\u003c?php\n\nuse ElementaryFramework\\WaterPipe\\WaterPipe;\n\nuse ElementaryFramework\\WaterPipe\\HTTP\\Request\\Request;\n\nuse ElementaryFramework\\WaterPipe\\HTTP\\Response\\Response;\nuse ElementaryFramework\\WaterPipe\\HTTP\\Response\\ResponseStatus;\nuse ElementaryFramework\\WaterPipe\\HTTP\\Response\\ResponseHeader;\n\n// Create the root pipe\n$root = new WaterPipe;\n\n// Add a new route to the pipe with HTTP GET method (the home page)\n$root-\u003eget(\"/\", function (Request $req, Response $res) {\n    $res-\u003esendHtml(\"\u003cb\u003eWelcome to my web app !\u003c/b\u003e \u003ca href=\\\"/login\\\"\u003eClick here to login\u003c/a\u003e\");\n});\n\n// Add a new route to the pipe with HTTP GET method (the login page)\n$root-\u003eget(\"/login\", function (Request $req, Response $res) {\n    $res-\u003esendFile(\"./pages/login.html\", ResponseStatus::OkCode);\n});\n\n// Add a new route to the pipe with HTTP POST method (the login page form validation)\n$root-\u003epost(\"/login\", function (Request $req, Response $res) {\n    // Get $_POST values\n    $body = $req-\u003egetBody();\n    $username = $body[\"username\"];\n    $password = $body[\"password\"];\n\n    if (validate_username($username) \u0026\u0026 validate_password($password)) {\n        // Checks if the client access this route with an AJAX request\n        if ($req-\u003eisAjax()) {\n            $res-\u003esendJson(array(\n                \"success\" =\u003e true\n            ));\n        } else {\n            // Redirect the user to the members page\n            $res-\u003eredirect(\"/members/{$username}\");\n        }\n    } else {\n        // Checks if the client access this route with an AJAX request\n        if ($req-\u003eisAjax()) {\n            $res-\u003esendJson(array(\n                \"success\" =\u003e false\n            ));\n        } else {\n            // Redirect the user to the members page\n            $res-\u003eredirect(\"/login\");\n        }\n    }\n});\n\n// Add a new route to the pipe with HTTP GET method (the member's dashboard page)\n$root-\u003eget(\"/members/:username\", function (Request $req, Response $res) {\n    $res-\u003esendHtml(\"Welcome to your dashboard \u003cb\u003e{$req-\u003euri['username']}\u003c/b\u003e !\");\n});\n\n// Add a new HTTP error handler (the 404 Not Found Error)\n$root-\u003eerror(ResponseStatus::NotFoundCode, function (Request $req, Response $res) {\n    $res-\u003esendText(\"404 Error: Not Found.\", ResponseStatus::NotFoundCode);\n});\n\n// Finally... Run the pipe\n$root-\u003erun();\n```\n\n## Features\n\n- Highly designed to quickly create routes for MVC applications and REST services ;\n- Object Oriented HTTP [requests](https://github.com/ElementaryFramework/WaterPipe/blob/master/src/WaterPipe/HTTP/Request/Request.php) and [responses](https://github.com/ElementaryFramework/WaterPipe/blob/master/src/WaterPipe/HTTP/Response/Response.php) management ;\n- Full support for HTTP methods: GET, POST, PUT, DELETE, HEAD, PATCH and OPTIONS ;\n- Easily handle common HTTP errors (404, 500) ;\n- Designed to work with frontend frameworks like React.js, AngularJS, Vue.js, etc... with AJAX support\n\n## Installation\n\nYou can install **WaterPipe** in your project with [composer](http://getcomposer.org):\n\n```sh\ncomposer require elementaryframework/water-pipe\n```\n\nOnce installed, you can access the **WaterPipe** api through the `ElementaryFramework\\WaterPipe` namespace.\n\n## How to use ?\n\nNew to **WaterPipe** ? Learn how to build routing frameworks and REST services by browsing our [wiki](https://github.com/ElementaryFramework/WaterPipe/wiki).\n\n### Additional resources and tutorials\n\n- [How to create a RESTful API with PHP and the Elementary Framework](https://dev.to/na2axl/how-to-create-a-restful-api-with-php-and-the-elementary-framework-30ij) written by @na2axl on dev.to\n\n## Donate\n\nLiking Elementary Framework? Help us continue to maintain it and provide you better support and awesome functionalities with a small donation!\n\n[![Donate PayPal Button](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=AGAQAC3W4ZRMA\u0026source=url)\n\n## License\n\n\u0026copy; Copyright 2018-2020 Aliens Group.\n\nLicensed under MIT ([read license](https://github.com/ElementaryFramework/WaterPipe/blob/master/LICENSE))\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felementaryframework%2Fwaterpipe","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felementaryframework%2Fwaterpipe","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felementaryframework%2Fwaterpipe/lists"}