Download the PHP package lava83/laravel-sqid without Composer
On this page you can find all versions of the php package lava83/laravel-sqid. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download lava83/laravel-sqid
More information about lava83/laravel-sqid
Files in lava83/laravel-sqid
Package laravel-sqid
Short Description 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.
License MIT
Homepage https://github.com/lava83/laravel-sqid
Informations about the package laravel-sqid
Laravel Sqid
A thin, idiomatic Laravel integration for Sqids. 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.
Requirements
- PHP
^8.3 - Laravel 12 or 13 (
illuminate/contracts^12.0||^13.0)
Installation
Install the package via Composer:
The service provider and the LaravelSqid facade are registered automatically via package discovery.
Optionally publish the config file:
Configuration
The published config/sqid.php looks like this:
All three options can be driven by environment variables:
| ENV variable | Config key | Description |
|---|---|---|
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
Facade
Helpers
Global helper functions are available everywhere:
Collection macro
A sqidsEncode() macro is mixed into Illuminate\Support\Collection:
Encoding only accepts integers
encode() (and therefore the helper and the collection macro) only accepts integers. Anything else throws an OnlyIntegersCanBeSqidEncoded exception:
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Stefan Riedel
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-sqid with dependencies
illuminate/contracts Version ^13.0
spatie/laravel-package-tools Version ^1.16
sqids/sqids Version ^0.5.0