Skip to content

Instantly share code, notes, and snippets.

@simensen
Created October 10, 2012 02:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simensen/3862808 to your computer and use it in GitHub Desktop.
Save simensen/3862808 to your computer and use it in GitHub Desktop.
dflydev/identity-generator and dflydev/identity-generator-dbal examples
<?php
// https://github.com/dflydev/dflydev-identity-generator
// https://github.com/dflydev/dflydev-identity-generator-dbal
use Dflydev\IdentityGenerator\DataStore\Dbal\DataStore;
use Dflydev\IdentityGenerator\Generator\RandomStringGenerator;
use Dflydev\IdentityGenerator\IdentityGenerator;
$maxLength = 10;
/*
* CREATE TABLE identityTableName (
* identityColumn string(10) unique
* );
*
*/
$dataStore = new DataStore($app['doctrine.dbal.connection'], 'identityTableName', 'identityColumn');
$generator = RandomStringGenerator::createBase32Crockford($maxLength);
$identityGenerator = new IdentityGenerator($dataStore, $generator);
// Guaranteed unique random string that is 10 characters long.
$identity = $identityGenerator->generate();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment