PHPackages                             mehdibo/paseto-bundle - 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. mehdibo/paseto-bundle

ActiveSymfony-bundle[Authentication &amp; Authorization](/categories/authentication)

mehdibo/paseto-bundle
=====================

A Symfony Bundle to use Paseto tokens

v1.0.0(4y ago)488MITPHPPHP ^7.4|^8.0|^8.1

Since Feb 25Pushed 4y ago1 watchersCompare

[ Source](https://github.com/mehdibo/paseto-bundle)[ Packagist](https://packagist.org/packages/mehdibo/paseto-bundle)[ RSS](/packages/mehdibo-paseto-bundle/feed)WikiDiscussions develop Synced 6d ago

READMEChangelog (1)Dependencies (8)Versions (4)Used By (0)

paseto-bundle
=============

[](#paseto-bundle)

[![License](https://camo.githubusercontent.com/ae54459381ee955685ea7ffb940c97e6c3dd127a47aa02d26781b7d47c23419f/68747470733a2f2f706f7365722e707567782e6f72672f6d65686469626f2f70617365746f2d62756e646c652f6c6963656e7365)](//packagist.org/packages/mehdibo/paseto-bundle)[![Latest Stable Version](https://camo.githubusercontent.com/e1034b16075fbb7ae192eb4fad21646da2715120cfe537e97166d79dbba98896/68747470733a2f2f706f7365722e707567782e6f72672f6d65686469626f2f70617365746f2d62756e646c652f76)](//packagist.org/packages/mehdibo/paseto-bundle)[![Latest Unstable Version](https://camo.githubusercontent.com/b8c35075d55bb1c7cd701f174a29ffab2eeffe7b9729a9d47026d61417712bf9/68747470733a2f2f706f7365722e707567782e6f72672f6d65686469626f2f70617365746f2d62756e646c652f762f756e737461626c65)](//packagist.org/packages/mehdibo/paseto-bundle)[![Total Downloads](https://camo.githubusercontent.com/6624ed587653f91f6ebc2adf167737ff8ddd7fa5e973c2cfe882f31346fbd9cc/68747470733a2f2f706f7365722e707567782e6f72672f6d65686469626f2f70617365746f2d62756e646c652f646f776e6c6f616473)](//packagist.org/packages/mehdibo/paseto-bundle)[![CI tests](https://github.com/mehdibo/paseto-bundle/actions/workflows/tests.yml/badge.svg)](https://github.com/mehdibo/paseto-bundle/actions/workflows/tests.yml)

PasetoBundle is a Symfony bundle to integrate [Paseto](https://github.com/paragonie/paseto/) into Symfony applications.

- [Installation](#installation)
    - [Install bundle](#step-1-install-bundle)
    - [Configuration](#step-2-configuration)
- [Usage](#installation)
    - [Creating Paseto tokens](#creating-paseto-tokens)
    - [Decoding Paseto tokens](#decoding-paseto-tokens)
    - [Commands](#commands)

Installation
============

[](#installation)

Make sure Composer is installed globally, as explained in the [installation chapter](https://getcomposer.org/doc/00-intro.md)of the Composer documentation.

### Step 1: Install bundle

[](#step-1-install-bundle)

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:

```
$ composer require mehdibo/paseto-bundle
```

### Step 2: Configuration

[](#step-2-configuration)

Add environment variables to `.env`:

```
###> mehdibo/paseto-bundle ###
PASETO_SYMMETRIC_KEY=
PASETO_ASYMMETRIC_SECRET_KEY=
###< mehdibo/paseto-bundle ###
```

You can generate keys using the bundle's command:

```
./bin/console mehdibo:paseto:generate-symmetric
./bin/console mehdibo:paseto:generate-generate-asymmetric
```

Create the configuration file `config/packages/mehdibo_paseto.yaml`

```
mehdibo_paseto:
  secret_keys:
    symmetric_key: '%env(PASETO_SYMMETRIC_KEY)%'
    asymmetric_key: '%env(PASETO_ASYMMETRIC_SECRET_KEY)%'
```

Then, enable the bundle by adding it to the list of registered bundles in the `config/bundles.php` file of your project:

```
// config/bundles.php

return [
    // ...
    Mehdibo\Bundle\PasetoBundle\MehdiboPasetoBundle::class => ['all' => true],
];
```

Usage
=====

[](#usage)

You can view the [`ExampleController`](./ExampleController.php) for a usage example.

### Creating Paseto tokens

[](#creating-paseto-tokens)

You can use the bundle's services to create tokens.

```
// For building local tokens
$localBuilder = new \Mehdibo\Bundle\PasetoBundle\Services\LocalPasetoBuilder();
// For building public tokens
$publicBuilder = new \Mehdibo\Bundle\PasetoBundle\Services\PublicPasetoBuilder();
```

From a controller:

```
namespace App\Controller;

use Mehdibo\Bundle\PasetoBundle\Services\LocalPasetoBuilder;
use Mehdibo\Bundle\PasetoBundle\Services\PublicPasetoBuilder;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

class TokensController extends AbstractController
{

    #[Route('/public', name: 'public')]
    public function public(PublicPasetoBuilder $builder): Response
    {
        $builder->setIssuedAt()->setClaims(['custom' => 'claim']);
        return new Response($builder->toString());
    }

    #[Route('/local', name: 'local')]
    public function local(LocalPasetoBuilder $builder): Response
    {
        $builder->setIssuedAt()->setClaims(['custom' => 'claim']);
        return new Response($builder->toString());
    }
}
```

### Decoding Paseto tokens

[](#decoding-paseto-tokens)

You can use the bundle's services to decode tokens

```
// For parsing local tokens
$localParser = new \Mehdibo\Bundle\PasetoBundle\Services\LocalPasetoParser();
// For parsing public tokens
$publicParser = new \Mehdibo\Bundle\PasetoBundle\Services\PublicPasetoParser();
```

From a controller:

```
namespace App\Controller;

use Mehdibo\Bundle\PasetoBundle\Services\LocalPasetoParser;
use Mehdibo\Bundle\PasetoBundle\Services\PublicPasetoParser;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Annotation\Route;

class TokensController extends AbstractController
{

    #[Route('/public/decode', name: 'public_decode')]
    public function publicDecode(PublicPasetoParser $parser): JsonResponse
    {
        $token = $parser->parse("PUBLIC_TOKEN_HERE");
        return new JsonResponse($token->getClaims());
    }

    #[Route('/local/decode', name: 'local_decode')]
    public function localDecode(LocalPasetoParser $parser): JsonResponse
    {
        $token = $parser->parse("LOCAL_TOKEN_HERE");
        return new JsonResponse($token->getClaims());
    }
}
```

### Commands

[](#commands)

The bundle provides some commands to help you use Paseto tokens.

```
mehdibo:paseto:generate-symmetric  # Generate a symmetric key
mehdibo:paseto:generate-asymmetric # Generate a asymmetric keys
mehdibo:paseto:generate-token      # Generate a Paseto token
```

```
$> ./bin/console mehdibo:paseto:generate-token --purpose local --expires_at P01D --claim uid --claim 13 --claim article_id --claim 37
v2.local.nn7biqHnkvU3JgJdfeVNqHlxsub_QEOsSAeGg2hdEVvPi_lxYwL01dSGjYw43P8PE0zorghJq2S6Czo8ztTxQ_UlSeYqPehXJ498Rk3Y9ouwqj2Z9j0Bk1uSbEBSqXPdr1GeeM0kpPk
```

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity63

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

Total

2

Last Release

1585d ago

Major Versions

v0.1.0-beta → v1.0.02022-01-13

PHP version history (2 changes)v0.1.0-betaPHP ^7.4|^8.0

v1.0.0PHP ^7.4|^8.0|^8.1

### Community

Maintainers

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

---

Top Contributors

[![mehdibo](https://avatars.githubusercontent.com/u/5004111?v=4)](https://github.com/mehdibo "mehdibo (101 commits)")

---

Tags

symfonybundleSymfony Bundlepaseto

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/mehdibo-paseto-bundle/health.svg)

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

###  Alternatives

[simplesamlphp/simplesamlphp

A PHP implementation of a SAML 2.0 service provider and identity provider.

1.1k12.4M193](/packages/simplesamlphp-simplesamlphp)[web-token/jwt-framework

JSON Object Signing and Encryption library for PHP and Symfony Bundle.

94518.9M77](/packages/web-token-jwt-framework)[web-auth/webauthn-framework

FIDO2/Webauthn library for PHP and Symfony Bundle.

50570.7k1](/packages/web-auth-webauthn-framework)[web-auth/webauthn-symfony-bundle

FIDO2/Webauthn Security Bundle For Symfony

63397.4k6](/packages/web-auth-webauthn-symfony-bundle)[tito10047/altcha-bundle

A simple package to help integrate Altcha on Symfony.

1610.9k1](/packages/tito10047-altcha-bundle)[adactive-sas/saml2-bridge-bundle

Symfony bundle that provide a SAML Identity Provider (idp).

123.5k](/packages/adactive-sas-saml2-bridge-bundle)

PHPackages © 2026

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