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

ActiveLibrary

mitch/hashids
=============

Laravel package for Hashids

1.0(11y ago)105108.8k—0%21[2 issues](https://github.com/mitchellvanw/hashids/issues)[2 PRs](https://github.com/mitchellvanw/hashids/pulls)PHPPHP &gt;=5.3.0

Since Sep 17Pushed 10y ago3 watchersCompare

[ Source](https://github.com/mitchellvanw/hashids)[ Packagist](https://packagist.org/packages/mitch/hashids)[ RSS](/packages/mitch-hashids/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (2)Versions (3)Used By (0)

Hashids for Laravel 4
=====================

[](#hashids-for-laravel-4)

This package uses the classes created by [hashids.org](http://www.hashids.org/ "http://www.hashids.org/")

**Generate hashes from numbers, like YouTube or Bitly. Use hashids when you do not want to expose your database ids to the user.**

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

[](#installation)

Begin by installing the package through Composer. Edit your project's `composer.json` file to require `mitch/hashids`.

```
"require": {
  "mitch/hashids": "1.x"
}
```

Next use Composer to update your project from the the Terminal:

```
php composer.phar update
```

Once the package has been installed you'll need to add the service provider. Open your `app/config/app.php` configuration file, and add a new item to the `providers` array.

```
'Mitch\Hashids\HashidsServiceProvider'
```

After doing this you also need to add an alias. In your `app/config/app.php` file, add this to the `aliases` array.

```
'Hashids' => 'Mitch\Hashids\Hashids'
```

Now last but not least you need to publish to package configuration from your Terminal:

```
php artisan config:publish mitch/hashids
```

Usage
-----

[](#usage)

Once you've followed all the steps and completed the installation you can use Hashids.

### Encoding

[](#encoding)

You can simply encrypt on id:

```
Hashids::encode(1); // Creating hash... Ri7Bi
```

or multiple..

```
Hashids::encode(1, 21, 12, 12, 666); // Creating hash... MMtaUpSGhdA
```

### Decoding

[](#decoding)

It's the same thing but the other way around:

```
Hashids::decode('Ri7Bi');

// Returns
array (size=1)
  0 => int 1
```

or multiple..

```
Hashids::decode('MMtaUpSGhdA');

// Returns
array (size=5)
  0 => int 1
  1 => int 21
  2 => int 12
  3 => int 12
  4 => int 666
```

### Injecting Hashids

[](#injecting-hashids)

Now it's also possible to have Hashids injected into your class. Lets look at this controller as an example..

```
class ExampleController extends BaseController
{
    protected $hashids;

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

    public function getIndex()
    {
        $hash = $this->hashids->encode(1);
        return View::make('example.index', compact('hash'));
    }
}
```

The original classname and namespace has been bound in the IoC container to return our instantiated Hashids class.

### Using IoC

[](#using-ioc)

Create a Hashids instance with the IoC

```
App::make('Hashids\Hashids')->encode(1);
```

That's it!
----------

[](#thats-it)

Documentation about [Hashids can be found here](https://github.com/ivanakimov/hashids.php).

Thanks to Ivan Akimov (@ivanakimov) for making Hashids. All credits for the Hashids package go to him.

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity47

Moderate usage in the ecosystem

Community19

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 84.9% 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 ~0 days

Total

2

Last Release

4203d ago

Major Versions

0.1 → 1.02014-09-17

### Community

Maintainers

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

---

Top Contributors

[![mitchellvanw](https://avatars.githubusercontent.com/u/3061428?v=4)](https://github.com/mitchellvanw "mitchellvanw (45 commits)")[![Garbee](https://avatars.githubusercontent.com/u/868301?v=4)](https://github.com/Garbee "Garbee (2 commits)")[![rmobis](https://avatars.githubusercontent.com/u/2119933?v=4)](https://github.com/rmobis "rmobis (2 commits)")[![tplaner](https://avatars.githubusercontent.com/u/50652?v=4)](https://github.com/tplaner "tplaner (2 commits)")[![kostaspt](https://avatars.githubusercontent.com/u/684680?v=4)](https://github.com/kostaspt "kostaspt (1 commits)")[![Pasvaz](https://avatars.githubusercontent.com/u/3006580?v=4)](https://github.com/Pasvaz "Pasvaz (1 commits)")

### Embed Badge

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

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

###  Alternatives

[kirkbushell/eloquence

A set of extensions adding additional functionality and consistency to Laravel's awesome Eloquent library.

573942.3k1](/packages/kirkbushell-eloquence)[spatie/laravel-mix-preload

Add preload and prefetch links based your Mix manifest

169175.3k2](/packages/spatie-laravel-mix-preload)

PHPackages © 2026

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