PHPackages                             terpomoj/base64-url-helpers - 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. terpomoj/base64-url-helpers

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

terpomoj/base64-url-helpers
===========================

Provides base64\_url\_encode/base64\_url\_decode.

v0.1.0(3y ago)11.0k1MITPHPPHP &gt;=8.0.0

Since Jun 1Pushed 3y agoCompare

[ Source](https://github.com/terpomoj/base64-url-helpers)[ Packagist](https://packagist.org/packages/terpomoj/base64-url-helpers)[ RSS](/packages/terpomoj-base64-url-helpers/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

🥔 `terpomoj/base64-url-helpers`
===============================

[](#-terpomojbase64-url-helpers)

This package provides two global functions: `base64_url_encode` and `base64_url_decode`. I found myself using these helpers in a lot of my projects.

What is Base64 URL?
-------------------

[](#what-is-base64-url)

In [RFC 3548](https://tools.ietf.org/html/rfc3548), Base64 URL is a variant of Base64 that uses the URL-safe alphabet. Which replaces the `+` and `/` characters in standard base64 with `-` and `_`. Padding character (`=`) can be optionally removed or retained.

Usage
-----

[](#usage)

Install with composer:

```
$ composer require terpomoj/base64-url-helpers
```

### Encode

[](#encode)

To encode:

```
$encoded = base64_url_encode('🏳️‍⚧️🏳️‍🌈');

// $encoded is now '8J-Ps--4j-KAjeKap--4j_Cfj7PvuI_igI3wn4yI'
```

There is also a second optional parameter to `base64_url_encode` that allow you to specify weather you want to remove padding characters or not. Which is default to `true`, that will remove padding characters.

```
$encode = base64_url_encode('🏳️‍⚧️');
// $encode = '8J-Ps--4j-KAjeKap004jw'

$encode = base64_url_encode('🏳️‍⚧️', removePadding: false);
// $encode = '8J-Ps--4j-KAjeKap004jw=='
```

### Decode

[](#decode)

To decode:

```
$decoded = base64_url_decode('8J-Ps--4j-KAjeKap--4j_Cfj7PvuI_igI3wn4yI');

// $decoded is now '🏳️‍⚧️🏳️‍🌈'
```

Just like PHP's native `base64_decode`, by default, it allows you to pass a string that is not a valid base64 string.

```
$decoded = base64_url_decode('8J-Ps--4j-KAjeKap--4j_Cfj7PvuI_igI3wn4yI!!!!!');
// $decoded is now '🏳️‍⚧️🏳️‍🌈'

$decoded = base64_url_decode('8J-Ps--4j-KAjeKap--4j_Cfj7PvuI_igI3wn4yI!!!!!', strict: true);
// $decodes is now false
```

Why?
----

[](#why)

The main reason I use URL-safe base64 is to encode binary UUID, so that the UUID in URL can be shorter than HEX-encoded UUID:

```
$uuid = base64_url_encode(Uuid::uuid4()->getBytes());
// $uuid is now 'oRZS8dRtR-GfBdCbaHwtkw'
```

License
-------

[](#license)

Licensed under `MIT`. See [LICENSE](LICENSE) file more details.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 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

1448d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/72963081?v=4)[BinotaLIU](/maintainers/binota)[@binota](https://github.com/binota)

---

Top Contributors

[![binotaliu](https://avatars.githubusercontent.com/u/67255597?v=4)](https://github.com/binotaliu "binotaliu (2 commits)")

---

Tags

base64helper-functionsphp

### Embed Badge

![Health badge](/badges/terpomoj-base64-url-helpers/health.svg)

```
[![Health](https://phpackages.com/badges/terpomoj-base64-url-helpers/health.svg)](https://phpackages.com/packages/terpomoj-base64-url-helpers)
```

PHPackages © 2026

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