PHP code example of rauny-henrique / php-proxy-server

1. Go to this page and download the library: Download rauny-henrique/php-proxy-server 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/ */

    

rauny-henrique / php-proxy-server example snippets


    
namespace App\Services\Proxy;
    
use Galdino\Proxy\Server\Request;
use Galdino\Proxy\Server\Response;
use Galdino\Proxy\Server\Contracts\RequestInterceptorContract;
use Galdino\Proxy\Server\ProxyMiddleware;
use Galdino\Proxy\Server\ProxyServer;

class MyProxyServer extends ProxyMiddleware implements RequestInterceptorContract
{
    protected $proxy;
    
    public function __construct()
    {
        $this->proxy = new ProxyServer($this);
    }
...


Then implement the middleware events:


...
public function onReceiveRequest(Request $request): Promise
{
    return new Promise(function ($resolve, $reject) use($request) {
        print 'Before client request' . PHP_EOL;

        //...

        $resolve($request);
    });