PHPackages                             digitaldream/symfony-access-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. digitaldream/symfony-access-token

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

digitaldream/symfony-access-token
=================================

Symfony Access Token Authentication Bundle.

1.0.0(2y ago)03MITPHPPHP ^8.2

Since Nov 1Pushed 2y ago1 watchersCompare

[ Source](https://github.com/digitaldreams/symfony-access-token-bundle)[ Packagist](https://packagist.org/packages/digitaldream/symfony-access-token)[ Docs](https://github.com/digitaldreams/symfony-access-token-bundle)[ RSS](/packages/digitaldream-symfony-access-token/feed)WikiDiscussions main Synced 1mo ago

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

Symfony Access Token Bundle
===========================

[](#symfony-access-token-bundle)

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

[](#installation)

```
composer require digitaldream/symfony-access-token

```

Setup
-----

[](#setup)

**Step 1:**

copy `config/packages/access_token.yaml` from vendor folder

**Step 2**:

Copy `config/routes/access_token.yaml` from vendor folder

**Step 3**

Add these environment variables to your .env file

```
JWT_SECRET="YourSecretKey"
JWT_KEY=
JWT_ISSUER=localhost:8000
JWT_ALGORITHM=HS256
JWT_EXPIRE_AT='+24 hours'
```

**Step 4**

```
security:
    firewalls:
        api:
            pattern: ^/api
            provider: app_user_provider #your user provider
            stateless: true
            user_checker: AccessToken\Security\UserChecker
            access_token:
                token_handler: AccessToken\Security\AccessTokenHandler
                failure_handler: AccessToken\Security\AuthenticationFailureHandler
    access_control:
      - { path: ^/api, roles: ROLE_USER } # Change this line according to your project  USER ROlES
```

### Calling the Login API

[](#calling-the-login-api)

```
fetch('/api/login',{
   body: {
       username: 'john@example.com',
       password: 'YourPassword'
   }
})
```

You can create your own login route. Just remove package route and use `AccessToken\Services\CreateAccessTokenService`

```
namespace App\Controller

use AccessToken\Entity\AccessToken;
use AccessToken\Services\CreateAccessTokenService;
use AccessToken\Services\UserCredentialsRequest;
use Symfony\Component\HttpFoundation\Request;

class LoginController
{
    public function __construct(private  CreateAccessTokenService $accessTokenService) {}

    public function login(Request $request):
    {
        //Write your logic
        //@var AccessToken $accessToken
      $accessToken=  $this->accessTokenService->execute(new UserCredentialsRequest('YourEmail@example.com','YourPassword'))
    }
}
```

**Enjoy!!!**

Implement User verification and active feature
----------------------------------------------

[](#implement-user-verification-and-active-feature)

It will never generate a access token is user need to be email verified or inactive. Simply implement the `AccessToken\Entity\TokenUserInterface` on your `User` Entity like below

```
class User implements UserInterface, PasswordAuthenticatedUserInterface, TokenUserInterface
{

    public function isVerified(): ?bool
    {
       // return null if you don't have this functionality
        return true;
    }

    public function isActive(): ?bool
    {
        // return null if you don't have this functionality
        return true;
    }

    public function getUserIdentifierValue(): string
    {
        return $this->email;
    }

    public function getPublicId(): string
    {
        // It safe to use a UID (symfony UID) for generating JWT token. Do not expose your internal primary key
        return (string)$this->id;
    }
}
```

### Revoke Access Token

[](#revoke-access-token)

If you want to revoke all of the access token for a particular user then fire `AccessToken\Events\RevokeAccessTokensEvent`

```
namespace App\Controller;

use AccessToken\Events\RevokeAccessTokensEvent;
use \Symfony\Component\EventDispatcher\EventDispatcherInterface;

class SomeController {
 public function someAction(EventDispatcherInterface $dispatcher){
    //Do something with the User. E.g block or inactive or subscription expired.
    $dispatcher->dispatch(new RevokeAccessTokensEvent(1),RevokeAccessTokensEvent::NAME)
    }
}
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity55

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

Unknown

Total

1

Last Release

929d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/6059541?v=4)[Tuhin Bepari](/maintainers/digitaldreams)[@digitaldreams](https://github.com/digitaldreams)

---

Top Contributors

[![digitaldreams](https://avatars.githubusercontent.com/u/6059541?v=4)](https://github.com/digitaldreams "digitaldreams (6 commits)")

### Embed Badge

![Health badge](/badges/digitaldream-symfony-access-token/health.svg)

```
[![Health](https://phpackages.com/badges/digitaldream-symfony-access-token/health.svg)](https://phpackages.com/packages/digitaldream-symfony-access-token)
```

###  Alternatives

[scheb/2fa

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

578630.7k1](/packages/scheb-2fa)[scheb/2fa-bundle

A generic interface to implement two-factor authentication in Symfony applications

6914.0M62](/packages/scheb-2fa-bundle)[web-auth/webauthn-framework

FIDO2/Webauthn library for PHP and Symfony Bundle.

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

Symfony SDK for Auth0 Authentication and Management APIs.

128738.1k](/packages/auth0-symfony)[web-auth/webauthn-symfony-bundle

FIDO2/Webauthn Security Bundle For Symfony

63397.4k6](/packages/web-auth-webauthn-symfony-bundle)[klapaudius/oauth-server-bundle

Symfony(5.x to 8.x) OAuth Server Bundle

15547.3k2](/packages/klapaudius-oauth-server-bundle)

PHPackages © 2026

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