daaquan / sqids-ext
The most complete Sqids IDE stubs library which enables autocompletion in modern IDEs.
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Language:C
Requires
- php: >=7.4
- ext-gmp: *
Requires (Dev)
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2025-07-08 08:32:53 UTC
README
This repository contains a PHP extension built with Zephir that implements the Sqids algorithm. Sqids generates short, unique and seemingly random IDs from arrays of integers.
About Zephir
Zephir is an open source language designed to make it easy to create and maintain PHP extensions.
About Sqids
Sqids is a tiny library for generating short unique IDs from numbers. Think of it as base conversion with additional features.
See the FAQ for more details.
When to use Sqids
- Link shorteners
- Unique event IDs in logs
- Short codes for text messages
- Generating friend codes
Sqids is not meant for sensitive data because the IDs can be decoded back to the original numbers.
Building and Installing
- Build the extension from source using
phpize
andmake
(Zephir is only required when regenerating the C sources):
phpize ./configure --enable-sqids make sudo make install
- Enable the extension by adding the following line to your
php.ini
or using a dedicated.ini
file:
extension=sqids.so
Usage
<?php $sqids = new \Sqids\Sqids(); $id = $sqids->encode([1, 2, 3]); // "86Rf07" $numbers = $sqids->decode($id); // [1, 2, 3]
Running Tests
Install the development dependencies with Composer and execute PHPUnit:
composer install ./vendor/bin/phpunit ide-stubs/tests
All tests should pass and verify the behaviour of the extension.
Documentation
More documentation and API details are available at https://sqids.org/php.
Publishing to PECL
A basic package.xml
file is provided to simplify creating releases.
Generate the release archive using:
pear package
Upload the resulting .tgz
file on PECL.