Search by

byjg / shortid

byjg

Create short string IDs from numbers

Package info

github.com/byjg/php-shortid

pkg:composer/byjg/shortid

Statistics

Installs: 10 983

Dependents: 0

Suggesters: 0

Stars: 3

Open Issues: 0

6.0.0 2025-11-22 01:56 UTC

This package is auto-updated.

Last update: 2026-10-20 19:21:02 UTC


README

sidebar_key shortid
tags
php

ShortID

Create short string IDs from numbers

Sponsor Build Status Opensource ByJG Install MCP Server GitHub source GitHub license GitHub release

Description

This library enables you to create a very short string from integer numbers.

The basic usage is:

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

// Will write: hWifIaXiv9k

Documentation

Installation

composer require "byjg/shortid"

Quick Start

<?php
use ByJG\ShortId\ShortId;

// Create short ID from number
$shortid = ShortId::fromNumber(1234567890);

// Get the number back
$number = ShortId::get($shortid);

// Create from UUID
$shortid = ShortId::fromUuid('092395A6-BC87-11ED-8CA9-0242AC120002');

// Create from hex
$shortid = ShortId::fromHex('3e');

// Generate random short ID
$shortid = ShortId::fromRandom();

Running Tests

composer test

Open source ByJG