PHP code example of wearesho-team / token-generator
1. Go to this page and download the library: Download wearesho-team/token-generator 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/ */
wearesho-team / token-generator example snippets
use Wearesho\Token;
$generator = new Token\Generator\Number($length = 5);
$value = $generator->generate();
// value will contain number with 5 digits that can be converted to int
use Wearesho\Token;
$generator = new Token\Generator\Char($length = 5, $range = ['a', 'b', 'c']);
$value = $generator->generate();
// value will contain 5 characters from passed range in random sequence.
use Wearesho\Token;
$generator = new Token\Generator\Numeric($length = 5);
$value = $generator->generate();
// value will contain string from 5 digits and can start with `0`
use Wearesho\Token;
$generator = new Token\Generator\Environment($length = 5);
putenv('TOKEN_GENERATOR_VALUE=z');
$value = $generator->generate();
// value will contain 5 characters `z` that will be taken from environment.
use Wearesho\Token;
$generator = new Token\Generator\Environment($length = 5, 'ENV_PREFIX_', $default = new Token\Generator\Char(5, 'a'));
// In case your environment has not key ENV_PREFIX_VALUE, default generator will be used
// It will be also used in case of any exception in Environment generator
$value = $generator->generate();
// value be generated by default generator ('aaaaa')
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.