PHP code example of redirectionio / proxy-sdk

1. Go to this page and download the library: Download redirectionio/proxy-sdk 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/ */

    

redirectionio / proxy-sdk example snippets


$client = new RedirectionIO\Client\Sdk\Client($projectKey, $connections);
$request = new RedirectionIO\Client\Sdk\HttpMessage\Request(
    $_SERVER['HTTP_HOST'],
    $_SERVER['REQUEST_URI'],
    $_SERVER['HTTP_USER_AGENT'],
    $_SERVER['HTTP_REFERER']
);

$response = $client->request(new RedirectionIO\Client\Sdk\Command\MatchWithResponseCommand($request));

// There are no redirection for this Request
if (null === $response) {
    $response = '...'; // Handle your request with your application
}

$client->request(new RedirectionIO\Client\Sdk\Command\LogCommand($request, $response));

// Finally, Returns your response

use RedirectionIO\Client\Sdk\Client;

$client = new Client(string $projectKey, array $connections, int $timeout = 10000, bool $debug = false, LoggerInterface $logger = null);

    $projectKey = 'szio2389-bfdz-51e8-8468-02dcop129501:ep6a4805-eo6z-dzo6-aeb0-8c1lbmo40242';
    

    $connections = [
        'connection_tcp' => 'tcp://127.0.0.1:10301',
        'connection_unix' => 'unix:///var/run/redirectionio_agent.sock',
    ];

    

use RedirectionIO\Client\Sdk\Client;
use RedirectionIO\Client\Sdk\HttpMessage\Request;
use RedirectionIO\Client\Sdk\Command\MatchCommand;

$client->request(new MatchWithResponseCommand(Request $request);

use RedirectionIO\Client\Sdk\Client;
use RedirectionIO\Client\Sdk\HttpMessage\Request;
use RedirectionIO\Client\Sdk\Command\MatchCommand;

$client->request(new MatchCommand(Request $request);

use RedirectionIO\Client\Sdk\Client;
use RedirectionIO\Client\Sdk\Command\LogCommand;
use RedirectionIO\Client\Sdk\HttpMessage\Response;
use RedirectionIO\Client\Sdk\HttpMessage\Request;

$client->request(new LogCommand(Request $request, Response $response));