PHPackages                             amamarul/integer-hashids - 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. amamarul/integer-hashids

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

amamarul/integer-hashids
========================

Laravel Integers Hashids Generator. Encode and decode ids to Integers. Also generate prefixed hashids

1.0.1(8y ago)821.1k↓50%5[2 PRs](https://github.com/amamarul/integer-hashids/pulls)1MITPHP

Since Mar 22Pushed 2y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (3)Used By (1)

Laravel Integer Hashids
=======================

[](#laravel-integer-hashids)

#### Make Integers Hashids

[](#make-integers-hashids)

This package is an adaptation and combination of the following 3 packages:

- Laravel-Manager
- Hashids
- Laravel Hashids

This package works like [Laravel Hashids](https://github.com/vinkla/laravel-hashids "Laravel Hashids") but you can make integers hashids placing in alphabet connections only numbers and you can implement prefix ids. **Also you can use encode() and decode() helpers.***You can also make alphanumeric Hashids*

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

[](#installation)

### Composer require

[](#composer-require)

```
$ composer require amamarul/integer-hashids
```

### Add Provider into config/app.php

[](#add-provider-into-configappphp)

```
Amamarul\Hashids\HashidsServiceProvider::class,
```

### Publish config file

[](#publish-config-file)

```
$ php artisan vendor:publish --provider='Amamarul\Hashids\HashidsServiceProvider'
```

Usage
-----

[](#usage)

1. Setup the Config file (`config/hashids.php`) You can create differents connections with differents parameters

```
    'default' => 'main',
    'prefix-separator' => '-',

    '' => [
        'salt' => 'your-salt-string',
        'length' => '10',
        'alphabet' => '0123456789',
        'prefix' => null,
    ],
```

- Name Connection: There are a 'main' connection that is used by default but you can create custom connections and then call them.
- salt: is a phrase string.
- length: Number of characters you need
- alphabet: you can set any character to make the hash, but if you want integer hashid keep the same ('0123456789').
- prefix: if you want a prefixed hashid you can add the prefix, if not you can omit it or delete the parameter.
- prefix-separator: If you use a prefix maybe do you want to use a prefix separator. If not leave empty ('').
- default: you can change the default connection

2. With 'main' connection and without 'prefix' (`'prefix' => null`)

```
  use Hashids;

  Hashids::encode(1548);
  // output: 7988887798

  Hashids::decode('7988887798');
  // output: 1548
```

3. With 'main' connection and with 'prefix' (`'prefix' => 'AA'`)

```
  use Hashids;

  Hashids::encode(1548);
  // output: AA-7988887798

  Hashids::decode('AA-7988887798');
  // output: 1548
```

4. With 'custom' name connection and with and without 'prefix'

```
  use Hashids;

  Hashids::connection('custom')->encode(1548);
  // output: 7988887798

  Hashids::connection('custom')->decode('7988887798');
  // output: 1548
```

5. If you prefer to use dependency injection over facades, you can inject the manager:

- With 'main' connection ```
      use Amamarul\Hashids\Support\HashidsManager;

      class Foo
      {
      	protected $hashids;

      	public function __construct(HashidsManager $hashids)
      	{
      		$this->hashids = $hashids;
      	}

      	public function encode($id)
      	{
      		$this->hashids->encode($id)
      	}

      	public function decode($hashid)
      	{
      		$this->hashids->decode($hashid)
      	}
      }
    ```
- With 'custom' connection ```
      use Amamarul\Hashids\Support\HashidsManager;

      class Foo
      {
      	protected $hashids;

      	public function __construct(HashidsManager $hashids)
      	{
      		$this->hashids = $hashids->connection('custom');
      	}

      	public function encode($id)
      	{
      		$this->hashids->encode($id)
      	}

      	public function decode($hashid)
      	{
      		$this->hashids->decode($hashid)
      	}
      }
    ```

Helpers
-------

[](#helpers)

You can use the 'encode()' and 'decode()' helpers

- encode()

```
  // with 'main' connection
  encode($id)
  // with 'custom' connection
  encode($id,'custom')
```

- decode()

```
  // with 'main' connection
  decode($hashid)
  // with 'custom' connection
  decode($hashid,'custom')
```

### Feel free to send improvements

[](#feel-free-to-send-improvements)

Created by [Maru Amallo-amamarul](https://github.com/amamarul "https://github.com/amamarul")

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity35

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity64

Established project with proven stability

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

Total

2

Last Release

3055d ago

### Community

Maintainers

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

---

Tags

integers-hashidslaravellaravel-54laravel-54-hashidslaravel-integers-hashidsprefixed-hashidsprefixed-integer-hashidslaravellaravel 5.4Laravel Integers HashidsLaravel 5.4 hashidsIntegers HashidsPrefixed hashidsPrefixed integer hashids

### Embed Badge

![Health badge](/badges/amamarul-integer-hashids/health.svg)

```
[![Health](https://phpackages.com/badges/amamarul-integer-hashids/health.svg)](https://phpackages.com/packages/amamarul-integer-hashids)
```

###  Alternatives

[stephenjude/filament-blog

Filament Blog Builder

20317.8k](/packages/stephenjude-filament-blog)[ralphjsmit/laravel-helpers

A package containing handy helpers for your Laravel-application.

13704.6k2](/packages/ralphjsmit-laravel-helpers)[datomatic/nova-detached-actions

A Laravel Nova tool to allow for placing actions in the Nova toolbar detached from the checkbox selection mechanism.

11229.2k](/packages/datomatic-nova-detached-actions)

PHPackages © 2026

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