PHPackages                             oneduo/laravel-human-keys - 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. [Database &amp; ORM](/categories/database)
4. /
5. oneduo/laravel-human-keys

ActiveLibrary[Database &amp; ORM](/categories/database)

oneduo/laravel-human-keys
=========================

Provides configurable and customizable Stripe-like keys for your Eloquent models

v0.1.2(3y ago)35911[3 PRs](https://github.com/oneduo/laravel-human-keys/pulls)MITPHPPHP ^8.0

Since Jan 11Pushed 2y ago2 watchersCompare

[ Source](https://github.com/oneduo/laravel-human-keys)[ Packagist](https://packagist.org/packages/oneduo/laravel-human-keys)[ Docs](https://github.com/oneduo/laravel-human-keys)[ GitHub Sponsors](https://github.com/oneduo)[ RSS](/packages/oneduo-laravel-human-keys/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (3)Dependencies (15)Versions (7)Used By (0)

Laravel Human Keys
==================

[](#laravel-human-keys)

[![Latest Version on Packagist](https://camo.githubusercontent.com/2604d135ff47ce080722d309e33f730325340acf36cb28a547a4802118954623/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6f6e6564756f2f6c61726176656c2d68756d616e2d6b6579732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/oneduo/laravel-human-keys)[![GitHub Tests Action Status](https://camo.githubusercontent.com/bf0424192911cb5fefe919ecd15b1ce629cc9507f5ee873db0173860faa411f6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6f6e6564756f2f6c61726176656c2d68756d616e2d6b6579732f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/oneduo/laravel-human-keys/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/ade60575786de48dc29c95010d8214cffe40c567d595a45d0ba3779c1e06c2c0/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6f6e6564756f2f6c61726176656c2d68756d616e2d6b6579732f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/oneduo/laravel-human-keys/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/b7424f53f10c8dc9d4ca8623cb3c30a29dca8f57fe1d72639184d4c7d90bcef7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6f6e6564756f2f6c61726176656c2d68756d616e2d6b6579732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/oneduo/laravel-human-keys)

A package to use human readable keys in your Laravel models. Inspired by Stripe's id generation procedures.

Enables you to have KSUID keys in your models, which are human readable and sortable.

Example:

- `pos_2JvL8Gv5mirjbIVAlSRFrC8EaWR` for `Models/Post.php`
- `usr_p6UEyCc8D8ecLijAI5zVwOTP3D0` for `Models/User.php`

Table of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Usage](#usage)
- [Changelog](#changelog)
- [Contributing](#contributing)
- [Credits](#credits)
- [License](#license)

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

[](#installation)

You can install the package via composer:

```
composer require oneduo/laravel-human-keys
```

You can publish the config file with:

```
php artisan vendor:publish --tag="human-keys-config"
```

This is the contents of the published config file:

```
return [
    /*
    |--------------------------------------------------------------------------
    | Generator
    |--------------------------------------------------------------------------
    |
    | Used to define the generator to use for generating model keys.
    |
    | Supported:
    |   - ksuid (abc_p6UEyCc8D8ecLijAI5zVwOTP3D0)
    |   - snowflake (abc_1537200202186752)
    |
    | Default: ksuid
    |
    | Note: You may define your own generator by implementing the contract
    |       Oneduo\LaravelHumanKeys\Contracts\Generator and passing
    |       the class name to the generator config option.
    |
    |       See the example below:
    |       'generator' => \App\Services\MyGenerator::class
    */
    'generator' => 'ksuid',
];
```

Usage
-----

[](#usage)

To get started, use the `HasHumanKey` trait in your model:

```
namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Oneduo\LaravelHumanKeys\Concerns\HasHumanKey;

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

When using the `ksuid` generator, the generated key will something like this: `pos_2JvL8Gv5mirjbIVAlSRFrC8EaWR`

When using the `snowflake` generator, the generated key will something like this: `pos_451734027389370636`

### Overriding the key prefix

[](#overriding-the-key-prefix)

You may set your own key prefix for each model by implementing the following method:

```
namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Oneduo\LaravelHumanKeys\Concerns\HasHumanKey;

class Post extends Model
{
    use HasHumanKey;

    public static function getKeyPrefix() : string {
        // prefix without _ underscore as it gets added by the generator
        return 'post_prefix'
    }
}
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Charaf Rezrazi](https://github.com/rezrazi)
- [All Contributors](../../contributors)
- [godruoyi/php-snowflake](https://github.com/godruoyi/php-snowflake)
- [tuupola/ksuid](https:/:github.com/tuupola/ksuid)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

28

—

LowBetter than 51% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~12 days

Total

3

Last Release

1283d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5689944?v=4)[Mikaël Popowicz](/maintainers/mikaelpopowicz)[@mikaelpopowicz](https://github.com/mikaelpopowicz)

![](https://avatars.githubusercontent.com/u/2086576?v=4)[Charaf Rezrazi](/maintainers/Rezrazi)[@Rezrazi](https://github.com/Rezrazi)

---

Top Contributors

[![Rezrazi](https://avatars.githubusercontent.com/u/2086576?v=4)](https://github.com/Rezrazi "Rezrazi (14 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (10 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (7 commits)")

---

Tags

eloquentkeysksuidlaravelmodelssnowflakestripelaravelstripemodeluuidkeyssnowflakeksuidoneduolaravel-human-keys

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/oneduo-laravel-human-keys/health.svg)

```
[![Health](https://phpackages.com/badges/oneduo-laravel-human-keys/health.svg)](https://phpackages.com/packages/oneduo-laravel-human-keys)
```

###  Alternatives

[spatie/laravel-permission

Permission handling for Laravel 12 and up

13.0k107.5M1.6k](/packages/spatie-laravel-permission)[dedoc/scramble

Automatic generation of API documentation for Laravel applications.

2.2k12.6M135](/packages/dedoc-scramble)[lacodix/laravel-model-filter

A Laravel package to filter, search and sort models with ease while fetching from database.

17562.4k](/packages/lacodix-laravel-model-filter)[wnx/laravel-backup-restore

A package to restore database backups made with spatie/laravel-backup.

214456.3k2](/packages/wnx-laravel-backup-restore)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3915.5k](/packages/rawilk-profile-filament-plugin)[harris21/laravel-fuse

Circuit breaker for Laravel queue jobs. Protect your workers from cascading failures.

46273.9k](/packages/harris21-laravel-fuse)

PHPackages © 2026

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