2017 © Pedro Peláez
 

library shortid

Create short string IDs from numbers

image

byjg/shortid

Create short string IDs from numbers

  • Wednesday, December 20, 2017
  • by byjg
  • Repository
  • 1 Watchers
  • 2 Stars
  • 22 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 22 % Grown

The README.md

ShortID

Build Status Opensource ByJG GitHub source GitHub license GitHub release, (*1)

Create short string IDs from numbers, (*2)

Description

This library enables you to create a very short string from integer numbers., (*3)

The basic usage is:, (*4)

<?php
$shortid = \ByJG\Utils\ShortId::fromNumber(81717788171667188198);

// Will write: Qi0yuM2uKwJb

Methods

  • fromNumber($number, $map = null): Return a short id from a number
  • fromHex($hex, $map = null): Return a short id from a Hex value
  • fromUuid($uuid, $map = null): Return a short id from a UUID
  • fromRandom($min, $max, $map = null): Return a short id from a random number
  • get($shortid, $map = null): Return the Unique Integer Number from the short id (does not work with UUIDs)

Specify your own map

The base of the short id is in the map definition., (*5)

Basically, you can create your own sequence here., (*6)

The library defines four by default:, (*7)

  • $MAP_DEFAULT
  • $MAP_ALTERNATE
  • $MAP_NUMBERS_FIRST
  • $MAP_RANDOM

The basic usage is:, (*8)

<?php
$shortid = \ByJG\Utils\ShortId::fromNumber(
    81717788171667188198,
    \ByJG\Utils\ShortId::$MAP_NUMBERS_FIRST
);

// Will write: G8QokCSkAmz1

Installation

composer require "byjg/php-shortid"

Tests

vendor/bin/phpunit

Dependencies

flowchart TD  
    byjg/shortid  

Open source ByJG, (*9)

The Versions

20/12 2017

dev-master

9999999-dev

Create short string IDs from numbers

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

by João Gilberto Magalhães

20/12 2017

1.0.1

1.0.1.0

Create short string IDs from numbers

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

by João Gilberto Magalhães

20/12 2017

1.0.0

1.0.0.0

Create short string IDs from numbers

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

by João Gilberto Magalhães