daaquan/sqids-ext

There is no license information available for the latest version (v1.0.2) of this package.

The most complete Sqids IDE stubs library which enables autocompletion in modern IDEs.

v1.0.2 2025-07-08 08:21 UTC

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

  1. Build the extension from source using phpize and make (Zephir is only required when regenerating the C sources):
phpize
./configure --enable-sqids
make
sudo make install
  1. 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.