PHPackages                             projx-io/token - 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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. projx-io/token

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

projx-io/token
==============

1.3(10y ago)121[1 issues](https://github.com/projx-io/token/issues)PHP

Since Feb 18Pushed 10y agoCompare

[ Source](https://github.com/projx-io/token)[ Packagist](https://packagist.org/packages/projx-io/token)[ RSS](/packages/projx-io-token/feed)WikiDiscussions master Synced 4w ago

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

[![Build Status](https://camo.githubusercontent.com/04070f8c51221c6316548fe928a53384c455b45f950c0425a8dd9370541ae3c4/68747470733a2f2f7472617669732d63692e6f72672f70726f6a782d696f2f746f6b656e2e737667)](https://travis-ci.org/projx-io/token)

Tokenizer
=========

[](#tokenizer)

Install
-------

[](#install)

**composer**: `composer require projx-io/token`

Usage
-----

[](#usage)

```
  // The key used to encrypt the token. This ideally would not be random, and would be saved somewhere.
  $key = openssl_random_pseudo_bytes(32);

  $encoderBuilder = (new EncoderBuilder())
      ->validateEncode(new IsArrayValidation())     // 1. add encode validation encoder
      ->pack()                                      // 2. add pack encoder
      ->compress()                                  // 3. add gzip encoder
      ->encrypt($key)                               // 4. add encryption encoder
      ->base64()                                    // 5. add base64 encoder
      ->validateDecode(new IsStringValidation());   // 6. add decode validation encoder

  // The chain performs the following:
  //
  // Encoding (read chain from top to bottom):
  // 1. verify value is an array
  // 2. convert array into binary string
  // 3. gzip deflate
  // 4. encrypt with key and random vector (which is prepended to value to be read when decoding)
  // 5. encode binary into string via base64
  //
  // Decoding (read chain from bottom to top):
  // 6. verify that value is a string
  // 5. decode string into binary via base64
  // 4. decrypt binary with key and parsed vector
  // 3. gzip inflate
  // 2. parse binary string into array

  // The following builds the packer, which is an encoder that uses pack() to convert an array into a binary string.
  // With the following
  $encoderBuilder->packer()
      ->uint32BE('created')   // 1. encoding: expect 32bit int; decoding: name the int 'created'
      ->uint32BE('app_id')    // 2. encoding: expect 32bit int; decoding: name the int 'app_id'
      ->uint32BE('user_id');  // 3. encoding: expect 32bit int; decoding: name the int 'user_id'

  $encoder = $encoderBuilder->build();

  $token = $encoder->encodeToken([strtotime('now'), 5, 16]);
  echo json_encode($token) . "\n";
  // "9zxpVdE3QnDfAvTVcktpdz7R5A18rHP\/3ZXX9BaI"

  $decoded = $encoder->decodeToken($token);
  echo json_encode($decoded) . "\n";
  // {"created":1455760831,"app_id":5,"user_id":16}

```

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity67

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 ~30 days

Total

4

Last Release

3693d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7814b5d7789e9fa5beab6710a3e98826394dc3e8b09a2dd2a5306d058062e5f2?d=identicon)[projx](/maintainers/projx)

---

Top Contributors

[![chemisus](https://avatars.githubusercontent.com/u/394062?v=4)](https://github.com/chemisus "chemisus (29 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/projx-io-token/health.svg)

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

###  Alternatives

[league/oauth2-server

A lightweight and powerful OAuth 2.0 authorization and resource server library with support for all the core specification grants. This library will allow you to secure your API with OAuth and allow your applications users to approve apps that want to access their data from your API.

6.7k143.0M274](/packages/league-oauth2-server)[pimcore/pimcore

Content &amp; Product Management Framework (CMS/PIM/E-Commerce)

3.8k3.8M464](/packages/pimcore-pimcore)[silverstripe/mfa

Enable multi-factor authentication with fallback codes

10358.1k11](/packages/silverstripe-mfa)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

9317.2k55](/packages/open-dxp-opendxp)[jelix/jelix

Jelix PHP framework

84109.7k5](/packages/jelix-jelix)

PHPackages © 2026

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