PHPackages                             base62/base62 - 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. base62/base62

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

base62/base62
=============

base62 encoder and decoder also for big numbers with Laravel integration

3.1.1(7y ago)169.5k↑150%5MITPHPPHP &gt;=7.0.0CI failing

Since Jun 23Pushed 5y ago1 watchersCompare

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

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

Base62
======

[](#base62)

[![Build Status](https://camo.githubusercontent.com/8ce1032af2256dbc5f3c363d042ead287edb6e9533f3f5f4273c86d334d67037/68747470733a2f2f7472617669732d63692e6f72672f5369726f4469617a2f4261736536322e7376673f6272616e63683d646576656c6f70)](https://travis-ci.org/SiroDiaz/Base62)[![paypal](https://camo.githubusercontent.com/e1ff554a09e8e92bef25abc553ff05b88f45afd695877cf12f3a46558ef65b2e/68747470733a2f2f7777772e70617970616c6f626a656374732e636f6d2f656e5f55532f692f62746e2f62746e5f646f6e61746543435f4c472e676966)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3XKLA6VTYVSKW&source=url)

Base62 encoder and decorder also for big numbers. Useful to short database numeric ids in URLs.

requirements
------------

[](#requirements)

- requires PHP &gt;= 7.1.0 or higher
- Composer
- GMP (preferred) or BCMath extensions enabled.

Composer
--------

[](#composer)

```
$ composer require base62/base62

```

Laravel 5
---------

[](#laravel-5)

You just need to follow the composer command listed before and then you have to publish the base62.php config file into the config path of Laravel with the following command:

```
$ php artisan vendor:publish --tag=base62/base62

```

Then you can change in `config/base62.php` the default driver that is 'basic' (the PHP encoder implementation) for another supported by your host. It is recomended to use GMP extension because it is the most fast solution. Allowed encoders and decoders drivers are:

- basic
- gmp
- bcmath

Quick Start and Examples
------------------------

[](#quick-start-and-examples)

#### Methods

[](#methods)

encode and decode

#### Encoders/Decoders drivers

[](#encodersdecoders-drivers)

- basic
- gmp
- bcmath

#### Examples

[](#examples)

Encoding and decoding litle numbers.

```
require 'vendor/autoload.php';

use Base62\Base62;

$base62 = new Base62();		// by default use 'basic' driver. It is the default PHP encoder and decoder
$encodedValue = $base62->encode(200000);	// 'Q1O'
$decodedValue = $base62->decode($encodedValue); // 200000
```

Encoding and decoding big numbers. An important thing you must take in count: your PHP can be 32 or 64 bit, this means that a representation of an integer can take a maximum or 32 or 64 bit. This is a important limitation when you work with big integers, but for solve this problem we have GMP and BCMath native extensions for PHP.

```
require 'vendor/autoload.php';

use Base62\Base62;

// unsigned bigint (MySQL) 18446744073709551615
$id = '214748364787898954454';

$base62 = new Base62('gmp');
// print encoded base62 number id
$encodedValue = $base62->encode($id);	// '47rhmv5JHMPe'
$decodedValue = $base62->decode($base62->encode($id)); // '214748364787898954454'
```

Note that encode method uses strings as argument and not an integer. This is the best option by a simple reason. Imagine that you uses an integer that can not been represented by native PHP 32 or 64 bit interpreter, what would happen? Simple, the integer is truncated and can take negative values or a different positive number.

License
-------

[](#license)

[MIT License](https://opensource.org/licenses/MIT) Copyright © 2014-present, Siro Díaz Palazón

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity34

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 97.6% 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 ~79 days

Total

5

Last Release

2568d ago

PHP version history (2 changes)3.0.0PHP &gt;=5.6.0

3.1.0PHP &gt;=7.0.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7469286?v=4)[Siro Díaz Palazón](/maintainers/SiroDiaz)[@SiroDiaz](https://github.com/SiroDiaz)

---

Top Contributors

[![SiroDiaz](https://avatars.githubusercontent.com/u/7469286?v=4)](https://github.com/SiroDiaz "SiroDiaz (82 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (2 commits)")

---

Tags

base62big-intbigintbigintegercomposerdecoderencodinglaravellaravel-5-packagelaravel-frameworklaravel-packagephpshortenerurl-shortenerurllaravelstringBigIntegerbase62encoderdecoder

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

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

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

###  Alternatives

[cybercog/laravel-optimus

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

192564.1k](/packages/cybercog-laravel-optimus)[laracrafts/laravel-url-shortener

Powerful URL shortening tools in Laravel

97110.7k](/packages/laracrafts-laravel-url-shortener)[nahid/linkify

Converts URLs and email addresses in text into HTML links its extended from Misd\\Linify its also support laravel 5

11136.0k1](/packages/nahid-linkify)[iteks/laravel-enum

A comprehensive Laravel package providing enhanced enum functionalities, including attribute handling, select array conversions, and fluent facade interactions for robust enum management in Laravel applications.

2516.7k](/packages/iteks-laravel-enum)

PHPackages © 2026

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