jaam/silex-optimus-provider

A Silex Service Provider for the Optimus ID transformation library

v0.1 2017-02-09 18:10 UTC

This package is not auto-updated.

Last update: 2021-11-27 05:53:49 UTC


README

This library provides a Optimus service for the Silex framework.

Installation

composer require jaam/silex-optimus-provider

Usage

Full documentartion of the Optimus library can be found in its repository: https://github.com/jenssegers/optimus

Firstly, generate your Prime, Inverse Prime and Random values.

php vendor/bin/optimus spark

Feed these values into the container.

use Jaam\Silex\Provider\OptimusServiceProvider;

$app->register(new OptimusServiceProvider, [
    'optimus.options' => [
        'prime' => YOUR_PRIME
        'inverse' => YOUR_INVERSE
        'random' => YOUR_RANDOM
    ]
]);

$hashId = $app['optimus']->encode($myId);
$myId = $app['optimus']->decode($hashId);

Twig Extension

If the twig service is available, the service provider adds an extension enabling a Twig filter to use in your templates.

{{ my_id|optimus }}

Services

The provider exposes a optimus service. Please see the Optimus documentation for full usage.