2017 © Pedro Peláez
 

library php-proxy

image

sgmendez/php-proxy

  • Saturday, March 17, 2018
  • by sgmendez
  • Repository
  • 1 Watchers
  • 0 Stars
  • 284 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 76 Forks
  • 0 Open issues
  • 11 Versions
  • 37 % Grown

The README.md

php-proxy

Proxy script built on PHP, Symfony and cURL. This library borrows ideas from Glype, Jenssegers proxy, and Guzzle., (*1)

PHP-Proxy Web Application

If you're looking for a project version of this script that functions as a Web Application similar to Glype, then visit php-proxy-app, (*2)

See this php-proxy in action: UnblockVideos.com, (*3)

Installation

Install it using Composer:, (*4)

composer require sgmendez/php-proxy

Example

require('vendor/autoload.php');

use Proxy\Http\Request;
use Proxy\Proxy;

$request = Request::createFromGlobals();

$proxy = new Proxy();

$proxy->getEventDispatcher()->addListener('request.before_send', function($event){

    $event['request']->headers->set('X-Forwarded-For', 'php-proxy');

});

$proxy->getEventDispatcher()->addListener('request.sent', function($event){

    if($event['response']->getStatusCode() != 200){
        die("Bad status code!");
    }

});

$proxy->getEventDispatcher()->addListener('request.complete', function($event){

    $content = $event['response']->getContent();
    $content .= '<!-- via php-proxy -->';

    $event['response']->setContent($content);

});

$response = $proxy->forward($request, "http://www.yahoo.com");

// send the response back to the client
$response->send();

Plugin Example

namespace Proxy\Plugin;

use Proxy\Plugin\AbstractPlugin;
use Proxy\Event\ProxyEvent;

use Proxy\Html;

class MultiSiteMatchPlugin extends AbstractPlugin {

    // Matches multiple domain names (abc.com, abc.de, abc.pl) using regex (you MUST use / character)
    protected $url_pattern = '/^abc\.(com|de|pl)$/is';
    // Matches a single domain name
    //protected $url_pattern = 'abc.com';

    public function onCompleted(ProxyEvent $event){

        $response = $event['response'];

        $html = $response->getContent();

        // do your stuff here...

        $response->setContent($html);
    }
}

Notice that you must use the / character for regexes on $url_pattern, (*5)

The Versions

17/03 2018

dev-master

9999999-dev https://www.php-proxy.com/

  Sources   Download

MIT

The Requires

  • ext-curl *

 

php proxy php web proxy web proxy proxy script php proxy script

17/03 2018

v6.0

6.0.0.0 https://www.php-proxy.com/

  Sources   Download

MIT

The Requires

  • ext-curl *

 

php proxy php web proxy web proxy proxy script php proxy script

25/12 2017

v5.1.1

5.1.1.0 https://www.php-proxy.com/

  Sources   Download

MIT

The Requires

  • ext-curl *

 

php proxy php web proxy web proxy proxy script php proxy script

16/09 2017

v5.0.5

5.0.5.0 https://www.php-proxy.com/

  Sources   Download

The Requires

 

php proxy php web proxy web proxy proxy script php proxy script

24/06 2017

v5.0.4

5.0.4.0 https://www.php-proxy.com/

  Sources   Download

The Requires

 

php proxy php web proxy web proxy proxy script php proxy script

13/05 2017

v5.0.3

5.0.3.0 https://www.php-proxy.com/

  Sources   Download

The Requires

 

php proxy php web proxy web proxy proxy script php proxy script

07/05 2017

v5.0.2

5.0.2.0 https://www.php-proxy.com/

  Sources   Download

The Requires

 

php proxy php web proxy web proxy proxy script php proxy script

29/12 2016

v5.0.1

5.0.1.0 https://www.php-proxy.com/

  Sources   Download

The Requires

 

php proxy php web proxy web proxy proxy script php proxy script

18/06 2016

4.0.2

4.0.2.0 https://www.php-proxy.com/

  Sources   Download

The Requires

 

php proxy php web proxy web proxy proxy script

07/06 2015

3.0.0

3.0.0.0 https://www.php-proxy.com/

  Sources   Download

The Requires

 

php proxy php web proxy web proxy proxy script

11/01 2015

1.0.0

1.0.0.0 https://www.php-proxy.com/

  Sources   Download

The Requires

 

php proxy php web proxy web proxy