Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Athlon1600/php-proxy
A web proxy script written in PHP and built as an alternative to Glype.
https://github.com/Athlon1600/php-proxy
glype php-proxy
Last synced: 14 days ago
JSON representation
A web proxy script written in PHP and built as an alternative to Glype.
- Host: GitHub
- URL: https://github.com/Athlon1600/php-proxy
- Owner: Athlon1600
- License: mit
- Created: 2015-01-05T19:03:02.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2023-07-06T16:31:34.000Z (over 1 year ago)
- Last Synced: 2024-08-01T19:34:01.242Z (3 months ago)
- Topics: glype, php-proxy
- Language: PHP
- Homepage: https://www.php-proxy.com
- Size: 521 KB
- Stars: 298
- Watchers: 28
- Forks: 158
- Open Issues: 53
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![](https://img.shields.io/packagist/dm/athlon1600/php-proxy) ![](https://img.shields.io/github/last-commit/athlon1600/php-proxy)
php-proxy
=========Proxy script built on PHP, Symfony and cURL.
This library borrows ideas from Glype, Jenssegers proxy, and Guzzle.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**](https://github.com/Athlon1600/php-proxy-app)See this php-proxy in action:
proxy.unblockvideos.comInstallation
-------Install it using [Composer](http://getcomposer.org):
```bash
composer require athlon1600/php-proxy
```Example
--------```php
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 .= '';
$event['response']->setContent($content);
});$response = $proxy->forward($request, "http://www.yahoo.com");
// send the response back to the client
$response->send();```
Plugin Example
--------```php
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```