1. Go to this page and download the library: Download gpslab/base64uid 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/ */
gpslab / base64uid example snippets
use GpsLab\Component\Base64UID\Base64UID;
$uid = Base64UID::generate(); // iKtwBpOH2E
$generator = new RandomBytesGenerator();
$uid = $generator->generate(); // YCfGKBxd9k4
$generator = new RandomBytesGenerator(5);
$uid = $generator->generate(); // Mm7dpkM
$binary_generator = new RandomBinaryGenerator(32);
$encoder = new HexToBase64BitmapEncoder();
$generator = new EncodeBitmapGenerator($binary_generator, $encoder);
$uid = $generator->generate(); // 7MWx2BuWJUw
$binary_generator = new TimeBinaryGenerator();
$encoder = new HexToBase64BitmapEncoder();
$generator = new EncodeBitmapGenerator($binary_generator, $encoder);
$uid = $generator->generate(); // koLfRhzAoI0
$uid = $generator->generate(); // zALfRhzAovg
$uid = $generator->generate(); // 18LfRhzAoQw
$binary_generator = new FloatingTimeGenerator();
$encoder = new HexToBase64BitmapEncoder();
$generator = new EncodeBitmapGenerator($binary_generator, $encoder);
$uid = $generator->generate(); // 5mqhb6MPH7g
$uid = $generator->generate(); // kFvow8joJys
$uid = $generator->generate(); // 8QRC30YeP3E
$generator_id = 0; // value 0-1023
$binary_generator = new SnowflakeGenerator($generator_id);
$encoder = new HexToBase64BitmapEncoder();
$generator = new EncodeBitmapGenerator($binary_generator, $encoder);
$uid = $generator->generate(); // gBFKQeuAAAA
$uid = $generator->generate(); // gBFKQeuAAAE
$uid = $generator->generate(); // gBFKQevAAAA
class ArticleId
{
private $id;
public function __construct(string $id)
{
$this->id = $id;
}
public function id()
{
return $this->id;
}
}
interface ArticleRepository
{
public function nextId();
// more methods ...
}
use GpsLab\Component\Base64UID\Base64UID;
class ConcreteArticleRepository implements ArticleRepository
{
public function nextId()
{
return new ArticleId(Base64UID::generate());
}
// more methods ...
}
$article = new Article(
$repository->nextId(),
// more article parameters ...
);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.