Created
October 10, 2012 02:28
-
-
Save simensen/3862808 to your computer and use it in GitHub Desktop.
dflydev/identity-generator and dflydev/identity-generator-dbal examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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