create composer.json
{
"require": {
"colindev/proxy": "v1.*"
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/colindev/php-proxy.git"
}
]
}
$ composer install
create example.php
<?php
include __DIR__.'/vendor/autoload.php';
$proxy = new proxy\Proxy('http://host.of.target[:port]');
// $proxy->prefix('/prefix');
$res = $proxy->exec($_SERVER);
foreach ($res->headers as $k => $vs) {
foreach ($vs as $i => $v) {
header("${k}: ${v}");
}
}
echo $res->body;
$ php -S 0.0.0.0:8000 example.php