Download the PHP package istiak-tridip/laravel-sqids without Composer
On this page you can find all versions of the php package istiak-tridip/laravel-sqids. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download istiak-tridip/laravel-sqids
More information about istiak-tridip/laravel-sqids
Files in istiak-tridip/laravel-sqids
Package laravel-sqids
Short Description Laravel wrapper for Sqids to obscure database IDs with unique, URL-safe identifiers.
License MIT
Homepage https://github.com/istiak-tridip/laravel-sqids
Informations about the package laravel-sqids
π¦ Laravel Sqids
Laravel Sqids is a lightweight wrapper around Sqids (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:
- 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
Install the package via Composer:
[!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:
π Getting Started
To use Sqids with a model, simply add the HasSqids trait to your model:
π©βπ» Usage
π οΈ Accessing Sqids
You can access the Sqid directly from the model:
If needed, you can decode the Sqid back to the original ID:
π Query Helpers
When querying models using Sqids, you can use the provided query scopes instead of manually decoding the Sqids:
π Route Model Binding
The package automatically resolves route model bindings using Sqids. You can define your routes as usual:
In this example, the Invoice model will be resolved using the Sqid provided in the route.
π’ 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:
This ensures all generated Sqids consist only of numbers.
π Alternatives
If this package doesnβt meet your needs, here are some alternative packages you can explore:
-
red-explosion/laravel-sqids Another awesome Laravel package for integrating Sqids, offering a different implementation approach and features like prefixed Sqids.
- sqids/sqids-php The official PHP implementation of Sqids. Ideal for those who donβt require Laravel-specific integrations.
π License
Laravel Sqids was created by Istiak Tridip and is open-sourced under the MIT License.
All versions of laravel-sqids with dependencies
illuminate/contracts Version ^11.0||^12.0||^13.0
illuminate/support Version ^11.0||^12.0||^13.0
sqids/sqids Version ^0.5.0