PHP code example of rollerworks / uri-encoder-doctrine-cache

1. Go to this page and download the library: Download rollerworks/uri-encoder-doctrine-cache 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/ */

    

rollerworks / uri-encoder-doctrine-cache example snippets




use Doctrine\Common\Cache\ArrayCache;
use Doctrine\Common\Cache\ChainCache;
use Rollerworks\Component\UriEncoder\Encoder as UriEncoder;
use Rollerworks\Component\UriEncoder\Cache\DoctrineCache;

// The Doctrine cache library.
$doctrineCache = new ChainCache(
    [
        // Include the ArrayCache as the ChainCache will populate all the previous cache layers.
        // So if the `FilesystemCache` has a match it will populate the faster ArrayCache.
        new ArrayCache(),

        // Add an simple cache for fast access, eg. the rollerworks session-cache library.
        // https://github.com/rollerworks/Cache
    ]
);

// Rollerworks\Component\UriEncoder\CacheAdapterInterface
$cacheDriver = new DoctrineCache($doctrineCache);

$stringEncode = 'This string is not safe, for direct usage & must encoded';

$base64Encoder = new UriEncoder\Base64UriEncoder();
$cacheEncoder = new UriEncoder\CacheEncoderDecorator($cacheDriver, $base64Encoder);

$safeValue = $cacheEncoder->encodeUri($stringEncode);

// $safeString now contains a base64 encoded string
// and the result is cached using the cacheDriver.

$originalValue = $cacheEncoder->decodeUri($safeValue);
bash
$ php composer update rollerworks/uri-encoder-doctrine-cache