This package is abandoned and no longer maintained. No replacement package was suggested.

Provides a Doctrine Cache adapter for the Rollerworks URIEncoder Component

v1.0.0 2015-09-19 14:24 UTC


This package provides a Doctrine Cache adapter for the Rollerworks URIEncoder Component.


To install this package, add rollerworks/uri-encoder-doctrine-cache to your composer.json

$ php composer.phar require rollerworks/uri-encoder-doctrine-cache

Then, you can install the new dependencies by running Composer's update command from the directory where your composer.json file is located:

$ php composer update rollerworks/uri-encoder-doctrine-cache

Now, Composer will automatically download all required files, and install them for you.


require 'vendor/autoload.php';

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.

// 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);