Search by

A reversible base62-style ID obfuscator for modern PHP applications.

Package info

github.com/zackkitzmiller/tiny-php

pkg:composer/zackkitzmiller/tiny

Statistics

Installs: 211 362

Dependents: 1

Suggesters: 0

Stars: 398

Open Issues: 2

1.3.0 2017-02-07 15:14 UTC

This package is not auto-updated.

Last update: 2026-09-13 00:19:53 UTC


README

CI

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\Tiny facade alias
    • publish the config with php artisan vendor:publish --tag=tiny-config
    • set TINY_KEY in your environment or run php artisan tiny:generate
  • older Laravel integrations:
    • register ZackKitzmiller\TinyServiceProvider
    • optionally register the ZackKitzmiller\Facades\Tiny facade alias
    • publish the package configuration with the framework command your app version expects
    • run php artisan tiny:generate to persist the generated key