PHP code example of middlewares / proxy
1. Go to this page and download the library: Download middlewares/proxy library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
middlewares / proxy example snippets
$target = new Uri('http://api.example.com');
$dispatcher = new Dispatcher([
new Middlewares\Proxy($target)
]);
$response = $dispatcher->dispatch(new ServerRequest());
use Middlewares\Utils\Dispatcher;
use Middlewares\Utils\Factory;
$target = Factory::createUri('http://api.example.com');
Dispatcher::run([
new Middlewares\Proxy($target)
]);
$target = Factory::createUri('http://api.example.com');
$client = new Client();
$proxy = (new Middlewares\Proxy($target))->client($client);