calgamo / http-kernel
This package is abandoned and no longer maintained.
No replacement package was suggested.
Simple and generic library of HTTP request/response
0.3.3
2018-07-29 17:26 UTC
Requires
- php: >=7.0.0
- calgamo/exception: ~0.1
Requires (Dev)
- calgamo/test: ~0.1
- php-coveralls/php-coveralls: ^2.0
- phpunit/phpunit: ^6.3.0
This package is not auto-updated.
Last update: 2018-07-29 17:27:11 UTC
README
Description
Calgamo/HttpKernel is a HTTP foundation library for Calgamo Framwwork.
Feature
Demo
Example 1: how to use middleware and pipeline
use Calgamo\HttpKernel\MiddlewareInterface; use Calgamo\HttpKernel\RequestInterface; use Calgamo\HttpKernel\RequestHandlerInterface; use Calgamo\HttpKernel\Middleware\Pipeline; use Calgamo\HttpKernel\Request; class FirstMiddleware implements MiddlewareInterface { public function process(RequestInterface $request, RequestHandlerInterface $handler) { echo 'FirstMiddleware: 1' . PHP_EOL; $response = $handler->handle($request); echo 'FirstMiddleware: 2' . PHP_EOL; return $response; } } class SecondMiddleware implements MiddlewareInterface { public function process(RequestInterface $request, RequestHandlerInterface $handler) { echo 'SecondMiddleware: 1' . PHP_EOL; $response = $handler->handle($request); echo 'SecondMiddleware: 2' . PHP_EOL; return $response; } } class ThirdMiddleware implements MiddlewareInterface { public function process(RequestInterface $request, RequestHandlerInterface $handler) { echo 'ThirdMiddleware: 1' . PHP_EOL; $response = $handler->handle($request); echo 'ThirdMiddleware: 2' . PHP_EOL; return $response; } } $pipeline = new Pipeline(); $pipeline->push(new FirstMiddleware()); $pipeline->push(new SecondMiddleware()); $pipeline->push(new ThirdMiddleware()); $pipeline->run(new Request);
Output:
ThirdMiddleware: 1 SecondMiddleware: 1 FirstMiddleware: 1 FirstMiddleware: 2 SecondMiddleware: 2 ThirdMiddleware: 2
Usage
Requirement
PHP 7.0 or later
Installing Calgamo/HttpKernel
The recommended way to install Calgamo/HttpKernel is through Composer.
composer require calgamo/http-kernel
After installing, you need to require Composer's autoloader:
require 'vendor/autoload.php';
License
Author
Disclaimer
This software is no warranty.
We are not responsible for any results caused by the use of this software.
Please use the responsibility of the your self.