PHPackages                             rollerworks/uri-encoder - 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. rollerworks/uri-encoder

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

rollerworks/uri-encoder
=======================

A simple library, to safely encode a string for usage in a URI.

v2.1.0(2y ago)14.7k14MITPHPPHP ^8.1CI passing

Since Jun 20Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/rollerworks/uri-encoder)[ Packagist](https://packagist.org/packages/rollerworks/uri-encoder)[ RSS](/packages/rollerworks-uri-encoder/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (3)Versions (6)Used By (4)

Rollerworks UriEncoder
======================

[](#rollerworks-uriencoder)

This package provides the Rollerworks UriEncoder component, a simple library, to safely encode a string for usage in a URI. Plus a zlib compression.

**Caution:**

> Do not use this library for encoding authorization/reset tokens, as this will leak information. Only use this library to transport "public" information, like a filtering preference.
>
> Use [paragonie/constant\_time\_encoding](https://github.com/paragonie/constant_time_encoding)for time-safe en/decoding. Don't use conversion caching or compression for sensitive information!

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

[](#installation)

To install this package, add `rollerworks/search-uri-encoder` to your composer.json:

```
$ php composer.phar require rollerworks/search-uri-encoder
```

Now, [Composer](https://getcomposer.org/doc/00-intro.md) will automatically download all required files, and install them for you.

Requirements
------------

[](#requirements)

You need at least PHP 8.1, and optionally have support for gzip compression enabled.

This package has no other external dependencies.

Basic usage
-----------

[](#basic-usage)

The usage of this library is very straightforward, each encoder encodes and decodes a URL string.

To encode a string for safe usage in a URL call `encodeUri()` on the encoder. To decode an encoded string, to the original value call `decodeUri()` on the encoder.

**Note:** The `decode()` method will silently ignore invalid data, and return null instead.

### Base64UriEncoder

[](#base64uriencoder)

```
use Rollerworks\Component\UriEncoder\Encoder as UriEncoder;

$stringEncode = 'This string is not safe, for direct usage & must encoded';

$base64Encoder = new UriEncoder\Base64UriEncoder();

$safeValue = $base64Encoder->encodeUri($stringEncode);
// $safeValue now contains a base64 URI safe encoded string

$originalValue = $base64Encoder->decodeUri($safeValue);
```

### Decorators

[](#decorators)

To keep the encoders small special features are provided in the form of object decorators.

A decorator operates on top of the actual encoder.

- `encodeUri()` modifies the value returned by the decorated encoder.
- `decodeUri()` modifies the passed-in value before passing to the decorated encoder.

These decorators cannot be used as a stand-alone.

#### GZipCompressionDecorator

[](#gzipcompressiondecorator)

The `GZipCompressionDecorator` (de)compresses URI data.

**Caution:** The `GZipCompressionDecorator` creates a non-safe binary result, make sure the original encoder supports this.

```
use Rollerworks\Component\UriEncoder\Encoder as UriEncoder;

$stringEncode = 'This string is not safe, for direct usage & must encoded';

$base64Encoder = new UriEncoder\Base64UriEncoder();
$uriCompressor = new UriEncoder\GZipCompressionDecorator($base64Encoder);

$safeValue = $uriCompressor->encodeUri($stringEncode);
// $safeValue now contains a base64 encoded URI safe string, which internally contains the compressed result.

$originalValue = $uriCompressor->decodeUri($safeValue);
```

Versioning
----------

[](#versioning)

For transparency and insight into the release cycle, and for striving to maintain backward compatibility, this package is maintained under the Semantic Versioning guidelines as much as possible.

Releases will be numbered with the following format:

`..`

And constructed with the following guidelines:

- Breaking backward compatibility bumps the major (and resets the minor and patch)
- New additions without breaking backward compatibility bumps the minor (and resets the patch)
- Bug fixes and misc changes bumps the patch

For more information on SemVer, please visit .

License
-------

[](#license)

This library is released under the [MIT license](LICENSE).

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

[](#contributing)

This is an open source project. If you'd like to contribute, please read the [Contributing Guidelines](https://contributing.rollerscapes.net/). If you're submitting a pull request, please follow the guidelines in the [Submitting a Patch](https://contributing.rollerscapes.net/latest/patches.html) section.ß

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance56

Moderate activity, may be stable

Popularity24

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity76

Established project with proven stability

 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

Every ~856 days

Total

5

Last Release

926d ago

Major Versions

v1.1.0 → v2.0.02017-08-13

PHP version history (3 changes)v1.0.0PHP &gt;=5.3.3

v2.0.0PHP ^7.1

v2.1.0PHP ^8.1

### Community

Maintainers

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

---

Top Contributors

[![sstok](https://avatars.githubusercontent.com/u/904790?v=4)](https://github.com/sstok "sstok (39 commits)")

---

Tags

compressionencoderphpurirollerworks

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/rollerworks-uri-encoder/health.svg)

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

###  Alternatives

[vlucas/phpdotenv

Loads environment variables from `.env` to `getenv()`, `$\_ENV` and `$\_SERVER` automagically.

13.5k602.4M5.4k](/packages/vlucas-phpdotenv)[symfony/filesystem

Provides basic utilities for the filesystem

4.6k669.1M3.2k](/packages/symfony-filesystem)[friendsofphp/php-cs-fixer

A tool to automatically fix PHP code style

13.5k234.7M20.6k](/packages/friendsofphp-php-cs-fixer)[danielstjules/stringy

A string manipulation library with multibyte support

2.4k26.0M191](/packages/danielstjules-stringy)[rubix/ml

A high-level machine learning and deep learning library for the PHP language.

2.2k1.4M28](/packages/rubix-ml)[voku/portable-utf8

Portable UTF-8 library - performance optimized (unicode) string functions for php.

52322.4M40](/packages/voku-portable-utf8)

PHPackages © 2026

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