gerlovsky / php-short-id
Short ID generator. The library help you generate short id like youtube, vimeo, bit.ly, etc.
Installs: 22
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/gerlovsky/php-short-id
Requires
- php: >=5.4
Requires (Dev)
- phpunit/phpunit: ^4.8 || ^5.2 || ^6.2 || ^7.1
This package is not auto-updated.
Last update: 2025-10-16 07:10:55 UTC
README
The library help you generate short id like youtube, vimeo, bit.ly, etc. Short generation (creation) based on numerical ID.
Simple scenarios of using
require('vendor/autoload.php'); $shortId = new \Gerlovsky\ShortId\ShortId();
Creating short ID for a record from in a database
- when an app created a record in an your database with ID 20956
- $shortId->encode(20956) encodes it to 'bfrE'
- you updated the record for ID 20956 and set short_id of the record to 'bfrE'
$id = $shortId->encode(20956); // $id will be 'bfrE' // or with $length = 6 $id = $shortId->encode(20956, 6); // $id will be 'baauC6'