PHPackages                             uthman/hashid - 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. uthman/hashid

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

uthman/hashid
=============

Simple package to hash eloquent primary key, Forked from erashdan/hashid

1.2.1(4y ago)018PHPPHP ^7.4|^8.0

Since Jan 17Pushed 4y agoCompare

[ Source](https://github.com/OthmanAdlan/hashid)[ Packagist](https://packagist.org/packages/uthman/hashid)[ RSS](/packages/uthman-hashid/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (6)Versions (13)Used By (0)

Eloquent Hashid [![Build Status](https://camo.githubusercontent.com/08c4be4f4340b80cf044b66aee9b2b27429eaacf5afd2f6e190853e7d2208936/68747470733a2f2f7472617669732d63692e6f72672f657261736864616e2f6861736869642e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/erashdan/hashid)
============================================================================================================================================================================================================================================================================================

[](#eloquent-hashid-)

- [Installation](#installation)
- [Usage](#usage)
- [Testing](#testing)
- [Credits](#credits)
- [Todo](#todo)

This package hashes the primary key of an eloquent record.

```
// Get Hash ID
$user = \App\User::first();
$user->hashed_id;   //x7LR5oQJleJX60yPpNWV
```

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

[](#installation)

This package can be used in Laravel 5.5 or higher.

You can install the package via composer:

```
composer require erashdan/hashid
```

Laravel's package auto discovery will automatically register the service provider for you.

Then you need to publish the configuration to your project:

```
php artisan vendor:publish --provider="Erashdan\Hashid\HashidServiceProvider" --tag="config"
```

And add the key used for the hashing in .env file

```
HASHID_KEY=SET_YOUR_KEY
```

**OR**

Use Laravel's own app key, change the *key* parameter in `config/hashid.php` to Laravel's application key

```
'key' => env('APP_KEY'),
```

You can also change the length of the resulted hash from `.env` file.

```
HASHID_LENGTH=6
```

Usage
-----

[](#usage)

Eloquent by default doesn't implement hashid, so you should use the trait provided from the package.

```
use Illuminate\Database\Eloquent\Model;
use Erashdan\Hashid\Traits\Hashid;

class Post extends Model
{
    use Hashid;
```

You can then use the hashed\_id attribute on the eloquent object itself.

```
$post = \App\Models\Post::first();
$post->hashed_id; //x7LR5oQJleJX60yPpNWV
```

Or find a resource by hash

```
$post = \App\Models\Post::FindOrFailHashed('x7LR5oQJleJX60yPpNWV');
$post->id; //1
```

Validation
----------

[](#validation)

You can validate if hashed id is existed in model or not

```
    request()->validate([
        'post_id' => 'hashed_exists:' . \App\Post::class
    ]);
```

### Testing

[](#testing)

```
composer test
```

Credits
-------

[](#credits)

- [Emad Rashdan](https://github.com/erashdan)

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor1

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

Every ~165 days

Recently: every ~215 days

Total

8

Last Release

1522d ago

PHP version history (2 changes)1.0.0PHP &gt;=7.1.3

1.2.0PHP ^7.4|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/43986ca22ff7ef7e01e16f4a8b6e75147eb1a9ca5aa81cce42f713bbe6cb2404?d=identicon)[uthman](/maintainers/uthman)

---

Top Contributors

[![erashdan](https://avatars.githubusercontent.com/u/16059897?v=4)](https://github.com/erashdan "erashdan (15 commits)")[![OthmanAdlan](https://avatars.githubusercontent.com/u/52741796?v=4)](https://github.com/OthmanAdlan "OthmanAdlan (6 commits)")[![Yazan-Stash](https://avatars.githubusercontent.com/u/28860695?v=4)](https://github.com/Yazan-Stash "Yazan-Stash (2 commits)")[![OMA3DLAN](https://avatars.githubusercontent.com/u/66947017?v=4)](https://github.com/OMA3DLAN "OMA3DLAN (1 commits)")

---

Tags

phplaravelHashed ID

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/uthman-hashid/health.svg)

```
[![Health](https://phpackages.com/badges/uthman-hashid/health.svg)](https://phpackages.com/packages/uthman-hashid)
```

###  Alternatives

[larastan/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

6.4k43.5M5.2k](/packages/larastan-larastan)[ashallendesign/short-url

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

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

Psalm plugin for Laravel

3274.9M308](/packages/psalm-plugin-laravel)[laragear/preload

Effortlessly make a Preload script for your Laravel application.

119363.5k](/packages/laragear-preload)[deligoez/laravel-model-hashid

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

16498.0k](/packages/deligoez-laravel-model-hashid)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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