All Projects → ElementaryFramework → WaterPipe

ElementaryFramework / WaterPipe

Licence: MIT license
URL routing framework, requests/responses handler, and HTTP client for PHP

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to WaterPipe

request-on-steroids
An HTTP client ✨ with retry, circuit-breaker and tor support 📦 out-of-the-box
Stars: ✭ 19 (-20.83%)
Mutual labels:  http-client, request
Http Client
A high-performance, high-stability, cross-platform HTTP client.
Stars: ✭ 86 (+258.33%)
Mutual labels:  http-client, request
Ky
🌳 Tiny & elegant JavaScript HTTP client based on the browser Fetch API
Stars: ✭ 7,047 (+29262.5%)
Mutual labels:  http-client, request
Urllib
Request HTTP(s) URLs in a complex world
Stars: ✭ 600 (+2400%)
Mutual labels:  http-client, request
Wretch
A tiny wrapper built around fetch with an intuitive syntax. 🍬
Stars: ✭ 2,285 (+9420.83%)
Mutual labels:  http-client, request
Gout
gout to become the Swiss Army Knife of the http client @^^@---> gout 是http client领域的瑞士军刀,小巧,强大,犀利。具体用法可看文档,如使用迷惑或者API用得不爽都可提issues
Stars: ✭ 749 (+3020.83%)
Mutual labels:  http-client, request
Oh My Request
🔮 simple request library by java8
Stars: ✭ 44 (+83.33%)
Mutual labels:  http-client, request
Gretchen
Making fetch happen in TypeScript.
Stars: ✭ 301 (+1154.17%)
Mutual labels:  http-client, request
Baseokhttpv3
🔥OkHttp的二次封装库,提供各种快速使用方法以及更为方便的扩展功能。提供更高效的Json请求和解析工具以及文件上传下载封装,HTTPS和Cookie操作也更得心应手。
Stars: ✭ 121 (+404.17%)
Mutual labels:  http-client, request
Rxios
A RxJS wrapper for axios
Stars: ✭ 119 (+395.83%)
Mutual labels:  http-client, request
get-it
Composable HTTP request library for node and browsers
Stars: ✭ 19 (-20.83%)
Mutual labels:  http-client, request
chronosjs
JS Channels (Events / Commands / Reqest-Response / Courier) Mechanism
Stars: ✭ 35 (+45.83%)
Mutual labels:  request, response
Phin
Node HTTP client
Stars: ✭ 449 (+1770.83%)
Mutual labels:  http-client, request
oh-my-request
🔮 simple request library by java8
Stars: ✭ 41 (+70.83%)
Mutual labels:  http-client, request
Ky Universal
Use Ky in both Node.js and browsers
Stars: ✭ 421 (+1654.17%)
Mutual labels:  http-client, request
Create Request
Apply interceptors to `fetch` and create a custom request function.
Stars: ✭ 34 (+41.67%)
Mutual labels:  http-client, request
electron-request
Zero-dependency, Lightweight HTTP request client for Electron or Node.js
Stars: ✭ 45 (+87.5%)
Mutual labels:  http-client, request
axios-for-observable
A RxJS wrapper for axios, same api as axios absolutely
Stars: ✭ 13 (-45.83%)
Mutual labels:  http-client, request
Php Fetch
A simple, type-safe, zero dependency port of the javascript fetch WebApi for PHP
Stars: ✭ 95 (+295.83%)
Mutual labels:  http-client, response
reqres
Powerful classes for http requests and responses
Stars: ✭ 36 (+50%)
Mutual labels:  request, response

WaterPipe Logo

WaterPipe

downloads downloads downloads downloads

A powerful routing framework and requests/responses handler for PHP

WaterPipe is a library which allows you to easily handle HTTP requests and responses with PHP, giving you all the power to build a fully RESTful API, to create a routing framework for your web application, etc...

Example

<?php

use ElementaryFramework\WaterPipe\WaterPipe;

use ElementaryFramework\WaterPipe\HTTP\Request\Request;

use ElementaryFramework\WaterPipe\HTTP\Response\Response;
use ElementaryFramework\WaterPipe\HTTP\Response\ResponseStatus;
use ElementaryFramework\WaterPipe\HTTP\Response\ResponseHeader;

// Create the root pipe
$root = new WaterPipe;

// Add a new route to the pipe with HTTP GET method (the home page)
$root->get("/", function (Request $req, Response $res) {
    $res->sendHtml("<b>Welcome to my web app !</b> <a href=\"/login\">Click here to login</a>");
});

// Add a new route to the pipe with HTTP GET method (the login page)
$root->get("/login", function (Request $req, Response $res) {
    $res->sendFile("./pages/login.html", ResponseStatus::OkCode);
});

// Add a new route to the pipe with HTTP POST method (the login page form validation)
$root->post("/login", function (Request $req, Response $res) {
    // Get $_POST values
    $body = $req->getBody();
    $username = $body["username"];
    $password = $body["password"];

    if (validate_username($username) && validate_password($password)) {
        // Checks if the client access this route with an AJAX request
        if ($req->isAjax()) {
            $res->sendJson(array(
                "success" => true
            ));
        } else {
            // Redirect the user to the members page
            $res->redirect("/members/{$username}");
        }
    } else {
        // Checks if the client access this route with an AJAX request
        if ($req->isAjax()) {
            $res->sendJson(array(
                "success" => false
            ));
        } else {
            // Redirect the user to the members page
            $res->redirect("/login");
        }
    }
});

// Add a new route to the pipe with HTTP GET method (the member's dashboard page)
$root->get("/members/:username", function (Request $req, Response $res) {
    $res->sendHtml("Welcome to your dashboard <b>{$req->uri['username']}</b> !");
});

// Add a new HTTP error handler (the 404 Not Found Error)
$root->error(ResponseStatus::NotFoundCode, function (Request $req, Response $res) {
    $res->sendText("404 Error: Not Found.", ResponseStatus::NotFoundCode);
});

// Finally... Run the pipe
$root->run();

Features

  • Highly designed to quickly create routes for MVC applications and REST services ;
  • Object Oriented HTTP requests and responses management ;
  • Full support for HTTP methods: GET, POST, PUT, DELETE, HEAD, PATCH and OPTIONS ;
  • Easily handle common HTTP errors (404, 500) ;
  • Designed to work with frontend frameworks like React.js, AngularJS, Vue.js, etc... with AJAX support

Installation

You can install WaterPipe in your project with composer:

composer require elementaryframework/water-pipe

Once installed, you can access the WaterPipe api through the ElementaryFramework\WaterPipe namespace.

How to use ?

New to WaterPipe ? Learn how to build routing frameworks and REST services by browsing our wiki.

Additional resources and tutorials

Donate

Liking Elementary Framework? Help us continue to maintain it and provide you better support and awesome functionalities with a small donation!

Donate PayPal Button

License

© Copyright 2018-2020 Aliens Group.

Licensed under MIT (read license)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].