1. Go to this page and download the library: Download dduers/php-rest-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/ */
dduers / php-rest-proxy example snippets
$_proxy = new \Dduers\PhpRestProxy\RestProxy();
$_proxy->mount('myapi', 'http://localhost:8080/v1');
$_proxy->exec();
// set response headers
foreach ($_proxy->getHeaders() as $name_ => $value_)
header($name_.': '.$value_[0]);
// output response body
echo $_proxy->getBody();
$_proxy = new \Dduers\PhpRestProxy\RestProxy();
$_proxy->mount('myapi', 'http://localhost:8080/v1');
$_proxy->exec();
// output response body with response headers
echo $_proxy->dump();
$_proxy = new \Dduers\PhpRestProxy\RestProxy([
// for dev, don't verify ssl certs
'verify' => false,
// use HTTP/2
'version' => 2
]);
$_proxy->mount('srocki', 'https://domain19.local/v1');
$_proxy->exec();
$_proxy->dump();
setcookie('TestCookie', 'The Cookie Value', [
'expires' => time() + 60*60*24*30,
// set path to avoid multiple cookies generated for each api route
'path' => '/',
// domain, here the rest proxy is running
'domain' => '.domain17.local',
'secure' => false,
'httponly' => true,
'samesite' => 'Strict'
]);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.