> For the complete documentation index, see [llms.txt](https://web-token.spomky-labs.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://web-token.spomky-labs.com/v4.0/the-symfony-bundle/events.md).

# Events

How to use Symfony events

With the Symfony Bundle, you will be able to listen or subscribe to events.

All events can be found in the class `Jose\Bundle\JoseFramework\Event\Events`.

* **JWS:**
  * Events::JWS\_BUILT\_SUCCESS
  * Events::JWS\_BUILT\_FAILURE
  * Events::JWS\_VERIFICATION\_SUCCESS
  * Events::JWS\_VERIFICATION\_FAILURE
  * Events::JWS\_LOADING\_SUCCESS
  * Events::JWS\_LOADING\_FAILURE
* **JWE:**
  * Events::JWE\_BUILT\_SUCCESS
  * Events::JWE\_BUILT\_FAILURE
  * Events::JWE\_DECRYPTION\_SUCCESS
  * Events::JWE\_DECRYPTION\_FAILURE
  * Events::JWE\_LOADING\_SUCCESS
  * Events::JWE\_LOADING\_FAILURE
* **Nested Tokens:**
  * Events::NESTED\_TOKEN\_ISSUED Events::NESTED\_TOKEN\_LOADING\_SUCCESS Events::NESTED\_TOKEN\_LOADING\_FAILURE
* **Checked Header:**
  * Events::HEADER\_CHECK\_SUCCESS
  * Events::HEADER\_CHECK\_FAILURE
* **Checked Claim:**
  * Events::CLAIM\_CHECK\_SUCCESS
  * Events::CLAIM\_CHECK\_FAILURE

## Example:

{% code title="App\EventSubscriber\JwsSubscriber.php" %}

```php
<?php

declare(strict_types=1);

namespace App\EventSubscriber;

use Jose\Bundle\JoseFramework\Event\Events;
use Jose\Bundle\JoseFramework\Event\JWSBuiltSuccessEvent;
use Jose\Bundle\JoseFramework\Event\JWSVerificationFailureEvent;
use Jose\Bundle\JoseFramework\Event\JWSVerificationSuccessEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

class JwsSubscriber implements EventSubscriberInterface
{
    public static function getSubscribedEvents()
    {
        return [
            Events::JWS_VERIFICATION_SUCCESS => ['onJwsVerificationSuccess'],
            Events::JWS_VERIFICATION_FAILURE => ['onJwsVerificationFailure'],
            Events::JWS_BUILT_SUCCESS => ['onJwsBuiltSuccess'],
            Events::JWS_BUILT_FAILURE => ['onJwsBuiltFailure'],
        ];
    }

    public function onJwsVerificationSuccess(JWSVerificationSuccessEvent $event): void
    {
        // Do something here
    }

    public function onJwsVerificationFailure(JWSVerificationFailureEvent $event): void
    {
        // Do something here
    }

    public function onJwsBuiltSuccess(JWSBuiltSuccessEvent $event): void
    {
        // Do something here
    }

    public function onJwsBuiltFailure(JWSBuiltFailureEvent $event): void
    {
        // Do something here
    }
}
```

{% endcode %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://web-token.spomky-labs.com/v4.0/the-symfony-bundle/events.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
