Download the PHP package veelasky/laravel-hashid without Composer
On this page you can find all versions of the php package veelasky/laravel-hashid. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-hashid
Laravel HashId
Automatic HashId generator for your Laravel Eloquent models.
About
Laravel HashId provides an elegant way to add hashed IDs to your Eloquent models. It generates unique, non-sequential hashes for your model IDs and provides convenient methods to work with them.
✨ Latest Features
Version 3.2.3 introduces automatic route key generation, eliminating boilerplate code, along with enhanced secure route model binding and powerful column selection capabilities for full Laravel 11/12 and PHP 8.4 compatibility.
🚀 Automatic Route Key Generation (New in v3.2.3)
Zero boilerplate: The HashableId trait now automatically provides getRouteKey() method:
🔒 Secure Route Model Binding (New in v3.2.2)
Security improvement: Route model binding now only accepts valid hash values by default, preventing predictable ID enumeration attacks:
🔥 Column Selection API (New in v3.2.0)
Benefits:
- 🚀 Better Performance - Load only the columns you need
- 🔒 Type Safety - Automatic primary key inclusion when required
- 🔄 Backward Compatible - All existing code works unchanged
- 🎯 Smart Defaults -
['*']loads all columns, just like before - 🛡️ Enhanced Security - Prevents ID enumeration attacks by default
- ✅ Zero Boilerplate - No manual
getRouteKey()implementation needed
Compatibility
Modern Laravel Support (Recommended)
| Laravel HashId | PHP Version | Laravel 10 | Laravel 11 | Laravel 12 | Laravel 13 |
|---|---|---|---|---|---|
| 3.2 🌟 | ≥ 8.1 | ✅ | ✅ | ✅ | ✅ |
| 4.x 🚀 | ≥ 8.1 | ✅ | ✅ | ✅ | ✅ |
- 🌟 Stable Release (3.2) - Recommended for production
- 🚀 Development Branch (4.x) - Latest improvements
Full Version Matrix
| Laravel HashId | PHP Version | Laravel 6 | Laravel 7 | Laravel 8 | Laravel 9 | Laravel 10 | Laravel 11 | Laravel 12 | Laravel 13 |
|---|---|---|---|---|---|---|---|---|---|
| 1.x | ≥ 7.0 |
✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
| 2.x | ≥ 7.2 |
❌ | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ |
| 3.0 | ≥ 7.4 |
❌ | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ |
| 3.1 | ≥ 8.0 |
❌ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ |
| 3.2 🌟 | ≥ 8.1 |
❌ | ❌ | ❌ | ❌ | ✅ | ✅ | ✅ | ✅ |
| 4.x 🚀 | ≥ 8.1 |
❌ | ❌ | ❌ | ❌ | ✅ | ✅ | ✅ | ✅ |
📊 Version Recommendations:
- Laravel 6-9 → Use
3.0or3.1 - Laravel 10+ → Use
3.2(stable) or4.x(development) - Latest features → Use
3.2+with column selection support
Installation
With Laravel's package auto-discovery, the package will be automatically registered.
Quick Start
Simply add the HashableId trait to any Eloquent model you want to use with HashId:
Usage Examples
Basic Usage
Column Selection (New in v3.2)
Persisting HashId to Database
Route Model Binding
The trait automatically overwrites route methods to use HashId:
🔒 Secure Route Model Binding (Default)
By default, route model binding only accepts valid hash values and returns 404 for plain numeric IDs, preventing predictable ID enumeration attacks:
Optional Fallback to Numeric ID
If you need to support both hash and numeric ID resolution (not recommended for production), you can enable the fallback:
Custom Field Binding
Custom field binding always uses Laravel's default behavior:
🚀 Automatic Route Key Generation (New in v3.2.3)
The HashableId trait now automatically provides getRouteKey() method, so you don't need to implement it manually:
Before this version:
Benefits:
- ✅ Zero Boilerplate - No manual
getRouteKey()implementation needed - 🔄 Automatic - Works out of the box with the trait
- 🛡️ Consistent - Uses the same hash values as route resolution
- 🔧 Configurable - Respects custom hash column names
- ⬅️ Backward Compatible - Existing custom implementations still work
Validation Rules
Advanced Usage
Repository Pattern Access
Shared Hash Across Models
Configuration
You can configure HashId behavior using environment variables:
Or publish the configuration file:
License
MIT License. Feel free to use this package in your projects!
All versions of laravel-hashid with dependencies
hashids/hashids Version ^5.0
illuminate/contracts Version ^6.18|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0|^13.0
illuminate/config Version ^10.0|^11.0|^12.0|^13.0
illuminate/support Version ^10.0|^11.0|^12.0|^13.0
illuminate/validation Version ^10.0|^11.0|^12.0|^13.0
illuminate/database Version ^10.0|^11.0|^12.0|^13.0