PHPackages                             lava83/laravel-sqid - 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. lava83/laravel-sqid

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

lava83/laravel-sqid
===================

A thin Laravel integration for Sqids: encode lists of integers into short, URL-friendly strings and decode them back, configurable via alphabet, min\_length and blocklist.

v0.1.4(yesterday)02↑2900%MITPHPPHP ^8.3CI passing

Since Jun 10Pushed yesterdayCompare

[ Source](https://github.com/lava83/laravel-sqid)[ Packagist](https://packagist.org/packages/lava83/laravel-sqid)[ Docs](https://github.com/lava83/laravel-sqid)[ GitHub Sponsors](https://github.com/lava83)[ RSS](/packages/lava83-laravel-sqid/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (13)Versions (3)Used By (0)

Laravel Sqid
============

[](#laravel-sqid)

[![Latest Version on Packagist](https://camo.githubusercontent.com/ea5e87b093dce85f9fcf5e5188e77e20084710d1e062cef2ae98d6ec0d4b98e1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c61766138332f6c61726176656c2d737169642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/lava83/laravel-sqid)[![GitHub Tests Action Status](https://github.com/lava83/laravel-sqid/actions/workflows/run-tests.yml/badge.svg)](https://github.com/lava83/laravel-sqid/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://github.com/lava83/laravel-sqid/actions/workflows/fix-php-code-style-issues.yml/badge.svg)](https://github.com/lava83/laravel-sqid/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/ef6fca74fa259200e709778aa076eb39c08d739b8be0130012ade522d0c7bb99/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c61766138332f6c61726176656c2d737169642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/lava83/laravel-sqid)

A thin, idiomatic Laravel integration for [Sqids](https://sqids.org/). It encodes lists of integers into short, URL-friendly strings and decodes them back, configurable via `alphabet`, `min_length` and `blocklist`.

> **Note:** Sqids are **not** sequential, sortable or cryptographically secure, and they are **not** meant to replace database primary keys. They obfuscate integers into compact, unguessable-looking strings — for example to expose internal IDs in URLs without leaking the raw values.

```
use Lava83\LaravelSqid\Facades\LaravelSqid;

LaravelSqid::encode([1, 2, 3]);   // "86Rf07"
LaravelSqid::decode('86Rf07');    // Collection: [1, 2, 3]
```

Requirements
------------

[](#requirements)

- PHP `^8.3`
- Laravel 12 or 13 (`illuminate/contracts` `^12.0||^13.0`)

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

[](#installation)

Install the package via Composer:

```
composer require lava83/laravel-sqid
```

The service provider and the `LaravelSqid` facade are registered automatically via package discovery.

Optionally publish the config file:

```
php artisan vendor:publish --tag="laravel-sqid-config"
```

Configuration
-------------

[](#configuration)

The published `config/sqid.php` looks like this:

```
use Sqids\Sqids;

return [
    'min_length' => env('LARAVEL_SQID_MIN_LENGTH', Sqids::DEFAULT_MIN_LENGTH),
    'alphabet' => env('LARAVEL_SQID_ALPHABET', Sqids::DEFAULT_ALPHABET),
    'blocklist' => env('LARAVEL_SQID_BLOCKLIST', Sqids::DEFAULT_BLOCKLIST),
];
```

All three options can be driven by environment variables:

ENV variableConfig keyDescription`LARAVEL_SQID_MIN_LENGTH``min_length`Minimum length of the generated Sqid string.`LARAVEL_SQID_ALPHABET``alphabet`Custom alphabet used for encoding.`LARAVEL_SQID_BLOCKLIST``blocklist`Words that must not appear in any generated Sqid string.The underlying `Sqids\Sqids` instance is bound in the container from this config, so customizing the config is all you need.

Usage
-----

[](#usage)

### Facade

[](#facade)

```
use Lava83\LaravelSqid\Facades\LaravelSqid;

// Encode an array or a Collection of integers
LaravelSqid::encode([1, 2, 3]);          // "86Rf07"
LaravelSqid::encode(collect([1, 2, 3])); // "86Rf07"

// Decode back into a Collection
LaravelSqid::decode('86Rf07');           // collect([1, 2, 3])
```

### Helpers

[](#helpers)

Global helper functions are available everywhere:

```
sqid_encode([1, 2, 3]);   // "86Rf07"
sqid_decode('86Rf07');    // collect([1, 2, 3])
```

### Collection macro

[](#collection-macro)

A `sqidsEncode()` macro is mixed into `Illuminate\Support\Collection`:

```
collect([1, 2, 3])->sqidsEncode(); // "86Rf07"
```

### Encoding only accepts integers

[](#encoding-only-accepts-integers)

`encode()` (and therefore the helper and the collection macro) only accepts integers. Anything else throws an `OnlyIntegersCanBeSqidEncoded` exception:

```
use Lava83\LaravelSqid\Exceptions\OnlyIntegersCanBeSqidEncoded;

LaravelSqid::encode([1, 2, 'foo']); // throws OnlyIntegersCanBeSqidEncoded
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Stefan Riedel](https://github.com/lava83)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance100

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 Bus Factor1

Top contributor holds 93.8% 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

Unknown

Total

1

Last Release

1d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/bc7fb497f2f7531d21d0c7f814c34105a5c1be83dd4861c8d821b936c90f2374?d=identicon)[lava83](/maintainers/lava83)

---

Top Contributors

[![lava83](https://avatars.githubusercontent.com/u/16590655?v=4)](https://github.com/lava83 "lava83 (15 commits)")[![Copilot](https://avatars.githubusercontent.com/in/1143301?v=4)](https://github.com/Copilot "Copilot (1 commits)")

---

Tags

laravelencodedecodesqidsLava83url-friendlylaravel-sqid

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/lava83-laravel-sqid/health.svg)

```
[![Health](https://phpackages.com/badges/lava83-laravel-sqid/health.svg)](https://phpackages.com/packages/lava83-laravel-sqid)
```

###  Alternatives

[spatie/laravel-data

Create unified resources and data transfer objects

1.8k33.0M872](/packages/spatie-laravel-data)[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.3M42](/packages/spatie-laravel-pdf)[codewithdennis/filament-select-tree

The multi-level select field enables you to make single selections from a predefined list of options that are organized into multiple levels or depths.

328482.0k25](/packages/codewithdennis-filament-select-tree)[nativephp/desktop

NativePHP for Desktop

37833.6k8](/packages/nativephp-desktop)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

124581.3k](/packages/worksome-exchange)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3913.7k](/packages/rawilk-profile-filament-plugin)

PHPackages © 2026

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