PHPackages                             pfrug/hash-id - 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. pfrug/hash-id

ActiveLibrary

pfrug/hash-id
=============

Simple trait for Laravel to encode IDs in URLs, providing a secure and obfuscated way to expose model identifiers

v1.0.0(1y ago)05MITPHP

Since Feb 19Pushed 1y ago1 watchersCompare

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

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

HashId Laravel Package
======================

[](#hashid-laravel-package)

A simple trait for Laravel to encode IDs in URLs, providing a secure and obfuscated way to expose model identifiers.

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

[](#installation)

To install the package, run the following command:

```
composer require pfrug/hash-id
```

### Configuration

[](#configuration)

To publish the configuration file, use:

```
php artisan vendor:publish --tag="hashid-config"

```

This will create the `hashid.php` configuration file in the `config` directory.

Usage
-----

[](#usage)

1. To use the `HashId` trait, simply include it in your model:

```
use Pfrug\HashId;

class Post extends Model
{
    use HashId;
}
```

2. **Getting the encoded ID in the route**

In your route model binding, you can now use the encoded ID:

```
Route::get('/post/{post}', function (Post $post) {
    return $post;
});
```

This will automatically encode the `id` of your model in URLs.

### Regenerate Configuration Values

[](#regenerate-configuration-values)

If you want to regenerate the encoding values for `prime`, `inverse`, and `random`, you can use the following command:

```
php artisan hashid:regenerate

```

This will update the `hashid.php` configuration file with new values.

Running Tests
-------------

[](#running-tests)

To run the tests for the package, use the following command:

```
vendor/bin/phpunit --configuration "phpunit.xml" --filter=HashIdTest
```

License
-------

[](#license)

MIT License

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance43

Moderate activity, may be stable

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 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

453d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/bdea59e3f90698df3c5fa81e8b9f40e0444a32a1bc99270314ef976a90735e70?d=identicon)[frugone](/maintainers/frugone)

---

Top Contributors

[![pfrug](https://avatars.githubusercontent.com/u/5391920?v=4)](https://github.com/pfrug "pfrug (13 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/pfrug-hash-id/health.svg)

```
[![Health](https://phpackages.com/badges/pfrug-hash-id/health.svg)](https://phpackages.com/packages/pfrug-hash-id)
```

###  Alternatives

[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)[cybercog/laravel-optimus

An Optimus bridge for Laravel. Id obfuscation based on Knuth's multiplicative hashing method.

192564.1k](/packages/cybercog-laravel-optimus)[delight-im/ids

Short, obfuscated and efficient IDs for PHP

289.5k1](/packages/delight-im-ids)

PHPackages © 2026

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