colindev / php-proxy

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

php http proxy

Quick Start

step 1

create composer.json

{
    "require": {
        "colindev/proxy": "v1.*"
    },
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/colindev/php-proxy.git"
        }
    ]
}

step 2

$ composer install

step 3

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;

step 4

$ php -S 0.0.0.0:8000 example.php

step 5

open browser

About


Languages

Language:PHP 99.1%Language:Makefile 0.9%