zackkitzmiller / tiny
A reversible base62-style ID obfuscator for modern PHP applications.
Requires
- php: >=5.3.0
Requires (Dev)
- league/phpunit-coverage-listener: ~1.1
- phpunit/phpunit: ~3.7.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is not auto-updated.
Last update: 2026-09-13 00:19:53 UTC
README
Tiny
Tiny is a small reversible ID obfuscator for PHP. It encodes integers into a custom alphabet and decodes them back again.
What's modernized
- PHP 8.1+ baseline
- PSR-4 autoloading
- PHPUnit 10/11 test suite
- GitHub Actions CI
- Safer alphabet validation and decoding errors
Installation
composer require zackkitzmiller/tiny
Usage
<?php use ZackKitzmiller\Tiny; $tiny = new Tiny('5SX0TEjkR1mLOw8Gvq2VyJxIFhgCAYidrclDWaM3so9bfzZpuUenKtP74QNH6B'); echo $tiny->to(5); // E echo $tiny->from('E'); // 5 echo $tiny->to(126); // XX echo $tiny->from('XX'); // 126
Character set rules
Your alphabet must:
- contain at least 2 characters
- only contain unique characters
- stay fixed forever once you start issuing encoded IDs
Tiny throws an exception when the alphabet is invalid or when you try to decode characters that are not in the configured alphabet.
Generate an alphabet
After installing dependencies, generate a fresh 62-character alphabet with:
./bin/genset
You can also generate one in code:
$set = \ZackKitzmiller\Tiny::generateSet();
The legacy Tiny::generate_set() helper is still available for backwards compatibility.
This release does introduce a package-level modernization break: Composer autoloading now uses PSR-4 for ZackKitzmiller\\ classes, so consumers relying on older PSR-0-era assumptions should verify their integration when upgrading.
The Laravel integration classes continue to autoload from the ZackKitzmiller\\Laravel5\\ namespace under src/ZackKitzmiller/Laravel5/.
Development
composer install
composer test
composer check
Legacy Laravel integration
The repository still includes the original Laravel integration classes for older applications, but the package is now centered on the framework-agnostic core library.
For Laravel integration:
- Laravel 5+:
- register
ZackKitzmiller\Laravel5\TinyServiceProvider - optionally register the
ZackKitzmiller\Facades\Tinyfacade alias - publish the config with
php artisan vendor:publish --tag=tiny-config - set
TINY_KEYin your environment or runphp artisan tiny:generate
- register
- older Laravel integrations:
- register
ZackKitzmiller\TinyServiceProvider - optionally register the
ZackKitzmiller\Facades\Tinyfacade alias - publish the package configuration with the framework command your app version expects
- run
php artisan tiny:generateto persist the generated key
- register