PHP code example of digidip / url-rewriter

1. Go to this page and download the library: Download digidip/url-rewriter 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/ */

    

digidip / url-rewriter example snippets


// Basic example of the implementation.

$redis = new \Redis();
$redis->connect('....');

$adapter = new RedisCircuitBreakerAdapter($redis);
$circuit = new CircuitBreaker($adapter);
$rewriter = new UrlRewriter($circuit, new DigidipSubdomainRewriterStrategy('mydomain'));

$url = $rewriter->getUrl('http://www.merchant.com');

// ... $url is used elsewhere as part of your implementation...

use digidip\UrlRewriter;

$urlRewriter = new UrlRewriter(
    // ... CircuitBreaker $circuitBreaker,
    // ... RewriterStrategy $strategy,
    // ... LoggerInterface $logger = null       (PSR Logger Instance)
);

$url = $urlRewriter->getUrl('https://www.a-merchant.com/'); // Return a URL whiuch is defined by the <Method>RewriterStrategy.

use digidip\CircuitBreaker;
use digidip\Adapters\FilePathCircuitBreakerAdapter;

$adapter = new FilePathCircuitBreakerAdapter('/path/to/file.json');
$circuit = new CircuitBreaker(
    $adapter,
    // ... ?array $options = [],
    // ... ?string $url = null,                 For testing purposes
    // ... ?Client $client = null,              For testing purposes
    // ... ?LoggerInterface $logger = null      (PSR Logger Instance)
);