PHPackages                             alexander-fuchs/hashidable - 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. alexander-fuchs/hashidable

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

alexander-fuchs/hashidable
==========================

Auto Hashids for Laravel Models and Routes

1.0.0(2y ago)05MITPHPPHP &gt;=8.0

Since Jul 19Pushed 2y agoCompare

[ Source](https://github.com/Alexander-Fuchs/hashidable)[ Packagist](https://packagist.org/packages/alexander-fuchs/hashidable)[ RSS](/packages/alexander-fuchs-hashidable/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (4)Versions (2)Used By (0)

Hashidable
==========

[](#hashidable)

> Hashidable uses [hashids](https://hashids.org/) to obfuscate Laravel route ids.

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

[](#installation)

*Note: This package is built to work with Laravel versions greater than 10. It may work in older version, but this has not been tested.*

```
composer require altinum/hashidable

```

Setup
-----

[](#setup)

Import the `Hashidable` trait and add it to your model.

```
use Altinum\Hashidable\Hashidable;

Class User extends Model
{
  use Hashidable;
}
```

Usage
-----

[](#usage)

```
$user = User::find(1);

$user->id; // 1
$user->hashid; // 3RwQaeoOR1E7qjYy

User::find(1);
User::findByHashId('3RwQaeoOR1E7qjYy');
User::findByHashidOrFail('3RwQaeoOR1E7qjYy');
```

### Route Model Binding

[](#route-model-binding)

Assuming we have a route resource defined as follows:

```
Route::apiResource('users', UserController::class);
```

This package does not affect route model bindings, the only difference is, instead of placing the id in the generated route, it uses the hashid instead.

So, `route('users.show', $user)` returns `/users/3RwQaeoOR1E7qjYy`;

When you define your controller that auto-resolves a model in the parameters, it will work as always.

```
public function show(Request $request, User $user)
{
  return $user; // Works just fine
}
```

Configuring
-----------

[](#configuring)

First, publish the config file using:

```
php artisan vendor:publish --tag=hashidable.config

```

The available configuration options are:

```
return [
    /**
     * Length of the generated hashid.
     */
    'length' => 16,

    /**
     * Character set used to generate the hashids.
     */
    'charset' => 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890',

    /**
     * Prefix attached to the generated hash.
     */
    'prefix' => '',

    /**
     * Suffix attached to the generated hash.
     */
    'suffix' => '',

    /**
     * If a prefix of suffix is defined, we use this as a separator
     * between the prefix/suffix.
     */
    'separator' => '-',
];
```

### Per-Model Configuration

[](#per-model-configuration)

You can also extend the global configuration on a per-model basis. To do this, your model should implement the `Altinum\Hashidable\HashidableConfigInterface` and define the `hashidableConfig()` method on the model.

This method returns an array or subset of options similar to the global configuration.

```
    public function hashidableConfig()
    {
        return ['prefix' => 'app'];
    }
```

FAQs
----

[](#faqs)

 Where are the generated hashes stored?Hashidable does not touch the database to store any sort of metadata. What it does instead is use an internal encoder/decoder to dynamically calculate the hashes.

License
-------

[](#license)

[MIT](/LICENSE.md)

###  Health Score

22

—

LowBetter than 23% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity48

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

Unknown

Total

1

Last Release

1025d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e28c9b7859165060a33c8f3b05ea4aca09ab313d9e0f79b6e093966c721bd11a?d=identicon)[Alexander-Fuchs](/maintainers/Alexander-Fuchs)

---

Top Contributors

[![kayandra](https://avatars.githubusercontent.com/u/5002506?v=4)](https://github.com/kayandra "kayandra (18 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/alexander-fuchs-hashidable/health.svg)

```
[![Health](https://phpackages.com/badges/alexander-fuchs-hashidable/health.svg)](https://phpackages.com/packages/alexander-fuchs-hashidable)
```

###  Alternatives

[vinkla/hashids

A Hashids bridge for Laravel

2.1k13.3M71](/packages/vinkla-hashids)[ashallendesign/short-url

A Laravel package for creating shortened URLs for your web apps.

1.4k1.9M4](/packages/ashallendesign-short-url)[elfsundae/laravel-hashid

A simple, elegant way to obfuscate your data by generating reversible, non-sequential, URL-safe identifiers.

415246.3k2](/packages/elfsundae-laravel-hashid)[deligoez/laravel-model-hashid

Generate, Save, and Route Stripe/Youtube-like Hash IDs for Laravel Eloquent Models

16498.0k](/packages/deligoez-laravel-model-hashid)[solspace/craft-freeform

The most flexible and user-friendly form building plugin!

52664.9k12](/packages/solspace-craft-freeform)[torann/hashids

Laravel package for Hashids

54335.1k](/packages/torann-hashids)

PHPackages © 2026

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