PHPackages                             mindplay/payload - 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. mindplay/payload

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

mindplay/payload
================

Encode and decode small data-payloads using filename and URL-safe characters

1.0.0(9y ago)225MITPHPPHP &gt;=7

Since Feb 3Pushed 8y ago1 watchersCompare

[ Source](https://github.com/mindplay-dk/payload)[ Packagist](https://packagist.org/packages/mindplay/payload)[ RSS](/packages/mindplay-payload/feed)WikiDiscussions master Synced 2mo ago

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

mindplay/payload
================

[](#mindplaypayload)

This library lets you encode and decode small data-payloads into strings that can be safely used in filenames and URLs.

[![PHP Version](https://camo.githubusercontent.com/98e06ab279ef7d8f5dc610b12861b445a427f985f0ced740b6982d8fac4b3fe8/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d372e302532422d626c75652e737667)](https://packagist.org/packages/mindplay/payload)[![Build Status](https://camo.githubusercontent.com/f784ed093d8f20198be2efb0819a9a422af3794d2063e2dcf666327f110aa6be/68747470733a2f2f7472617669732d63692e6f72672f6d696e64706c61792d646b2f7265616461626c652e737667)](https://travis-ci.org/mindplay-dk/payload)

This can be useful for things like encoding resize/cropping-information into image URLs, creating personalized URLs for sharing things, etc.

The generated strings contain a small checksum as an integrity-check *only* - do **not** rely on this for "security by obscurity", the data-payload *can* be decoded and is by definition *not* secure or private in any way.

With that said, there is an option to prevent brute-force attacks, e.g. using a longer checksum and private salt - see [options](#options) below.

Usage
-----

[](#usage)

The service itself has no dependencies:

```
$service = new PayloadService();
```

To encode an array as a string:

```
$string = $service->encode(["hello" => "world"]); // "cMIDaGVsbG89d29ybGQ"
```

And to decode the string back to an array:

```
$data = $service->decode("cMIDaGVsbG89d29ybGQ") // ["hello" => "world"]
```

### Options

[](#options)

The constructor permits you to optionally enforce a maximum encoded length - this option is disabled by default. If enabled, `encode()` will throw if the encoded string-length is over the defined maximum.

You can optionally specify number of characters to append as a checksum - this is set to `4` by default. If you don't care about URL integrity, you can set this to zero.

If you're concerned about brute-force attacks against URLs, you can increase the checksum size, and optionally specify a private salt to seed the checksum - again, this does not provide strong security, but enough to prevent e.g. brute-force attacks against image URLs.

Refer to the [source-code](src/PayloadService.php) for inline documentation of options.

### Limitations

[](#limitations)

Only strings and arrays can be encoded. If your data contains integers, these will be converted to strings, and will arrive in string format when decoded.

### Some Advice

[](#some-advice)

Avoid encoding strings such as filenames, if you can - because the data is encoded in base64 format, it will increase in size, so a good filename strategy could be (for example) using an encoded string a prefix or suffix to a filename.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity64

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

Unknown

Total

1

Last Release

3388d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9445f567f43ee7a963270651e40e533634586f959e4df3d5398d001b1cb49be8?d=identicon)[mindplay.dk](/maintainers/mindplay.dk)

---

Top Contributors

[![mindplay-dk](https://avatars.githubusercontent.com/u/103348?v=4)](https://github.com/mindplay-dk "mindplay-dk (5 commits)")

### Embed Badge

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

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

###  Alternatives

[elgentos/magento2-structured-data

Implement structured data for Magento 2 webshops.

1444.7k](/packages/elgentos-magento2-structured-data)

PHPackages © 2026

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