PHPackages                             hallboav/silex-jwt-security - 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. hallboav/silex-jwt-security

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

hallboav/silex-jwt-security
===========================

JSON web token security provider for Silex 2.

v1.1(8y ago)47.0k↓100%3MITPHPPHP &gt;=5.5.9

Since Jul 18Pushed 8y ago1 watchersCompare

[ Source](https://github.com/hallboav/silex-jwt-security)[ Packagist](https://packagist.org/packages/hallboav/silex-jwt-security)[ RSS](/packages/hallboav-silex-jwt-security/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (4)Versions (3)Used By (0)

Silex JWT Security Service Provider
===================================

[](#silex-jwt-security-service-provider)

### Install

[](#install)

```
composer require hallboav/silex-jwt-security
```

### Usage

[](#usage)

#### Set up JSON web token application (which extends Application class from Silex)

[](#set-up-json-web-token-application-which-extends-application-class-from-silex)

This is required if you want to use the `JsonWebTokenTrait` trait.

```
use Hallboav\JsonWebTokenApplication;

$app = new JsonWebTokenApplication();
```

#### Register the service provider

[](#register-the-service-provider)

```
use Hallboav\Provider\JsonWebTokenSecurityServiceProvider;

$app->register(new JsonWebTokenSecurityServiceProvider());
```

#### Set up your Symfony's firewalls

[](#set-up-your-symfonys-firewalls)

```
use Silex\Provider\SecurityServiceProvider;

$providerKey = 'jwt0';
$app['security.user_provider.' . $providerKey] = function ($app) {
    return $app['security.jwt.user_provider'];
};

$app->register(new SecurityServiceProvider(), [
    'security.firewalls' => [
        $providerKey => [
            'pattern' => '^/admin', // any url that matches this pattern
            'stateless' => true,
            'guard' => [
                'authenticators' => [
                    'security.jwt.guard_authenticator'
                ]
            ]
        ]
    ]
]);
```

#### Examples of how to generate and retrieve your json web token (thanks to Luís Cobucci)

[](#examples-of-how-to-generate-and-retrieve-your-json-web-token-thanks-to-luís-cobucci)

```
use Symfony\Component\Security\Core\User\User;

$app->get('/get-token', function () use ($app) {
    $user = new User('hall', 'KIPP', ['ROLE_ADMIN']);

    $token = $app['security.jwt.builder']
        ->setExpiration(strtotime('+15 minutes'))
        ->set('username', $user->getUsername())
        ->set('roles', $user->getRoles())
        ->sign($app['security.jwt.default_signer'], $app['security.jwt.secret'])
        ->getToken();

    return $app->json(['token' => (string) $token]);
});

$app->get('/admin', function () use ($app) {
    $user = $app['user'];

    return $app->json([
        'user' => [
            'username' => $user->getUsername(),
            'roles' => $user->getRoles(),
            'token' => (string) $app->getToken()
        ]
    ]);
});
```

#### That's it!

[](#thats-it)

```
$app->run();
```

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity28

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity59

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

Every ~7 days

Total

2

Last Release

3213d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/56bbe5151114bd44c1837364f672f781769b2d3d179d01d9e0ae38c179c58b30?d=identicon)[hallboav](/maintainers/hallboav)

---

Top Contributors

[![hallboav](https://avatars.githubusercontent.com/u/12968370?v=4)](https://github.com/hallboav "hallboav (14 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/hallboav-silex-jwt-security/health.svg)

```
[![Health](https://phpackages.com/badges/hallboav-silex-jwt-security/health.svg)](https://phpackages.com/packages/hallboav-silex-jwt-security)
```

###  Alternatives

[tymon/jwt-auth

JSON Web Token Authentication for Laravel and Lumen

11.5k49.1M350](/packages/tymon-jwt-auth)[php-open-source-saver/jwt-auth

JSON Web Token Authentication for Laravel and Lumen

8359.8M53](/packages/php-open-source-saver-jwt-auth)[scheb/2fa

Two-factor authentication for Symfony applications (please use scheb/2fa-bundle to install)

578630.7k1](/packages/scheb-2fa)[patrickbussmann/oauth2-apple

Sign in with Apple OAuth 2.0 Client Provider for The PHP League OAuth2-Client

1132.5M6](/packages/patrickbussmann-oauth2-apple)[vonage/jwt

A standalone package for creating JWTs for Vonage APIs

424.1M4](/packages/vonage-jwt)[scheb/2fa-trusted-device

Extends scheb/2fa-bundle with trusted devices support

355.1M16](/packages/scheb-2fa-trusted-device)

PHPackages © 2026

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