PHPackages                             istiak-tridip/laravel-sqids - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. istiak-tridip/laravel-sqids

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

istiak-tridip/laravel-sqids
===========================

Laravel wrapper for Sqids to obscure database IDs with unique, URL-safe identifiers.

v0.0.3(1mo ago)25.4k↓33.7%1MITPHPPHP ^8.3CI passing

Since Apr 14Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/istiak-tridip/laravel-sqids)[ Packagist](https://packagist.org/packages/istiak-tridip/laravel-sqids)[ Docs](https://github.com/istiak-tridip/laravel-sqids)[ RSS](/packages/istiak-tridip-laravel-sqids/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (3)Dependencies (16)Versions (4)Used By (0)

🦑 Laravel Sqids
===============

[](#-laravel-sqids)

[![Test Status](https://camo.githubusercontent.com/56c8f6f04693731cf3528cdb6ac3e621851626950d981df98badb8819d801916/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f69737469616b2d7472696469702f6c61726176656c2d73716964732f72756e2d74657374732e79616d6c3f6c6162656c3d7465737473)](https://github.com/istiak-tridip/laravel-sqids/actions)[![Total Downloads](https://camo.githubusercontent.com/52ad1f4474e972a61c4713414bee5179970d63c32225bfaebb58902c0741a89b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f69737469616b2d7472696469702f6c61726176656c2d7371696473)](https://packagist.org/packages/istiak-tridip/laravel-sqids)[![Latest Version](https://camo.githubusercontent.com/50352bc5cfbef429e037ad05a209b8a9e064839df6d281a65721c1af657affdc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f69737469616b2d7472696469702f6c61726176656c2d7371696473)](https://packagist.org/packages/istiak-tridip/laravel-sqids)[![License](https://camo.githubusercontent.com/6a7357446137c1149141d6f9d1b4d8fe9067b28fe4921a43f9f3d91fd23ecddb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f69737469616b2d7472696469702f6c61726176656c2d7371696473)](https://packagist.org/packages/istiak-tridip/laravel-sqids)[![Laravel Compatibility](https://camo.githubusercontent.com/df351b1b3f1acbedd794494fd189561150a49e645793e0bd700137d9eba5d45f/68747470733a2f2f62616467652e6c61726176656c2e636c6f75642f62616467652f69737469616b2d7472696469702f6c61726176656c2d7371696473)](https://packagist.org/packages/istiak-tridip/laravel-sqids)

**Laravel Sqids** is a lightweight wrapper around [Sqids](https://sqids.org/) (pronounced "squids"), an open-source library for generating short, URL-safe, non-sequential, and unique identifiers from numbers.

This package simplifies the integration of Sqids into your Laravel application, providing a clean and efficient way to obscure raw database IDs in URLs, forms, or other scenarios where unique, aesthetically pleasing identifiers are needed without storing them in the database.

---

#### ✨ Features:

[](#-features)

- **Unique IDs**: Generates short, collision-free IDs that are unique to your application.
- **Model-Specific IDs**: Produces distinct IDs for each model to ensure uniqueness across models.
- **Route Model Binding**: Automatically resolves route model bindings with the generated IDs.
- **Convenient Helpers**: Includes query scopes for easy filtering and an option to configure numeric-only IDs.

Installation
------------

[](#installation)

Install the package via Composer:

```
composer require istiak-tridip/laravel-sqids
```

Important

This package requires **PHP 8.3 or higher** and is compatible with **Laravel 11.x, 12.x and 13.x**.

If you need to customize the default configuration, publish the config file:

```
php artisan vendor:publish --tag=sqids-config
```

🚀 Getting Started
-----------------

[](#-getting-started)

To use Sqids with a model, simply add the `HasSqids` trait to your model:

```
use Istiak\Sqids\Concerns\HasSqids;

class User extends Model
{
    use HasSqids;
}
```

👩‍💻 Usage
---------

[](#‍-usage)

### 🛠️ Accessing Sqids

[](#️-accessing-sqids)

You can access the Sqid directly from the model:

```
$user = User::query()->first();

echo $user->refid; // Outputs the Sqid for the model's ID
```

If needed, you can decode the Sqid back to the original ID:

```
// Throws an exception on failure
$id = $user->sqids()->decode($user->refid);

// Returns null on failure
$id = $user->sqids()->decodeOrNull($user->refid);
```

---

### 🔍 Query Helpers

[](#-query-helpers)

When querying models using Sqids, you can use the provided query scopes instead of manually decoding the Sqids:

```
// Find a single model by Sqid
$user = User::query()->whereSqid($sqid)->first();

// Find multiple models by Sqids
$users = User::query()->whereSqidIn([$sqid1, $sqid2])->get();
```

---

### 🔗 Route Model Binding

[](#-route-model-binding)

The package automatically resolves route model bindings using Sqids. You can define your routes as usual:

```
// GET /invoices/86Rf07xd4z
Route::get('/invoices/{record}', function (Invoice $record) {
    return $record->number;
});
```

In this example, the `Invoice` model will be resolved using the Sqid provided in the route.

---

### 🔢 Generating Numeric IDs

[](#-generating-numeric-ids)

If you need numeric-only Sqids (e.g., `4622014635`), configure the package to use a numeric alphabet in the `AppServiceProvider`'s `boot` method:

```
use Istiak\Sqids\Support\Config;

class AppServiceProvider extends ServiceProvider
{
    public function boot()
    {
        Config::generateNumericIds();
    }
}
```

This ensures all generated Sqids consist only of numbers.

🔄 Alternatives
--------------

[](#-alternatives)

If this package doesn’t meet your needs, here are some alternative packages you can explore:

- **[red-explosion/laravel-sqids](https://github.com/red-explosion/laravel-sqids)**Another awesome Laravel package for integrating Sqids, offering a different implementation approach and features like prefixed Sqids.
- **[sqids/sqids-php](https://github.com/sqids/sqids-php)**The official PHP implementation of Sqids. Ideal for those who don’t require Laravel-specific integrations.

📜 License
---------

[](#-license)

**Laravel Sqids** was created by [Istiak Tridip](https://github.com/istiak-tridip) and is open-sourced under the [MIT License](./LICENSE.md).

###  Health Score

45

—

FairBetter than 92% of packages

Maintenance89

Actively maintained with recent releases

Popularity28

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~191 days

Total

3

Last Release

55d ago

PHP version history (2 changes)v0.0.1PHP ^8.2

v0.0.3PHP ^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/b67fca5e68193eb9f6a2c36923e49470a754c19dc2cdec62dcd9912c784c8960?d=identicon)[istiak-tridip](/maintainers/istiak-tridip)

---

Top Contributors

[![istiak-tridip](https://avatars.githubusercontent.com/u/13367189?v=4)](https://github.com/istiak-tridip "istiak-tridip (26 commits)")

---

Tags

laravelaravel-sqidsphpsqidsphplaravelsqidslaravel-sqids

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/istiak-tridip-laravel-sqids/health.svg)

```
[![Health](https://phpackages.com/badges/istiak-tridip-laravel-sqids/health.svg)](https://phpackages.com/packages/istiak-tridip-laravel-sqids)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[larastan/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

6.4k51.0M7.6k](/packages/larastan-larastan)[laravel/ai

The official AI SDK for Laravel.

9782.1M162](/packages/laravel-ai)[moonshine/moonshine

Laravel administration panel

1.3k239.9k76](/packages/moonshine-moonshine)[red-explosion/laravel-sqids

Easily generate Stripe/YouTube looking IDs for your Laravel models.

4935.2k](/packages/red-explosion-laravel-sqids)[linkxtr/laravel-qrcode

A clean, modern, and easy-to-use QR code generator for Laravel

3614.9k](/packages/linkxtr-laravel-qrcode)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
