2017 © Pedro Peláez
 

library shortid

Short ID generator as alternative for public UUIDs

image

noxlogic/shortid

Short ID generator as alternative for public UUIDs

  • Thursday, May 4, 2017
  • by JayTaph
  • Repository
  • 2 Watchers
  • 1 Stars
  • 1 Installations
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

A simple short ID generator as an alternative for UUIDs, (*1)

This package is based on the blogpost: https://eager.io/blog/how-long-does-an-id-need-to-be/ and others., (*2)

Usage:, (*3)

composer require noxlogic/shortid

In your code:, (*4)

$id = ShortId::generate();

Or a bit more in control:, (*5)

$generator = new Gmp();
$encoder = new Base58();
$id = ShortId::generate($generator, $encoder);

Generators

These are the actual generators that converts the generated number. This can be done in multiple ways but by leveraging extensions like GMP (and possibly BCMATH) should speed up generation. Currently there is a plain generator and a GMP generator. When possible, the shortner will use GMP when available., (*6)

Encoders

This will convert the actual number into something that can be used on your website by encoding the data. There are two: base64, which will encode in a generic way, and base58 encoder, which will compact the number even a bit more. It will also generate only url-safe numbers by not using some url-unsafe characters that base64 uses., (*7)

The Versions

04/05 2017

dev-master

9999999-dev

Short ID generator as alternative for public UUIDs

  Sources   Download

MIT

The Requires

 

The Development Requires

by Joshua Thijssen