PHPackages                             vonage/jwt - 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. vonage/jwt

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

vonage/jwt
==========

A standalone package for creating JWTs for Vonage APIs

0.6.0(2mo ago)424.1M—3.5%53Apache-2.0PHPPHP ~8.1 || ~8.2 || ~8.3 || ~8.4 || ~8.5CI passing

Since Jul 21Pushed 2mo agoCompare

[ Source](https://github.com/Vonage/vonage-php-jwt)[ Packagist](https://packagist.org/packages/vonage/jwt)[ RSS](/packages/vonage-jwt/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (7)Dependencies (10)Versions (14)Used By (3)

JWT Client Library for PHP
==========================

[](#jwt-client-library-for-php)

[![Contributor Covenant](https://camo.githubusercontent.com/2757a9db291c5ceda172e31d4fa5f3c4048a6e6257ee0b7113f80de277074b91/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f436f6e7472696275746f72253230436f76656e616e742d76322e3025323061646f707465642d6666363962342e737667)](CODE_OF_CONDUCT.md)[![Build Status](https://github.com/vonage/vonage-php-jwt/workflows/build/badge.svg)](https://github.com/Vonage/vonage-php-jwt/actions?query=workflow%3Abuild)[![Latest Stable Version](https://camo.githubusercontent.com/985eaa42818043e67f6bcf7ce960b63bb9ddb42ccc62705d1974baaae6905343/68747470733a2f2f706f7365722e707567782e6f72672f766f6e6167652f6a77742f762f737461626c65)](https://packagist.org/packages/vonage/jwt)[![License](https://camo.githubusercontent.com/5b60841bea9e11d9d0b0950d690c9bc554e06385634056a7d5d62a15d1a4eabe/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4170616368655f322e302d626c75652e737667)](https://opensource.org/licenses/Apache-2.0)[![codecov](https://camo.githubusercontent.com/befa627ff1b229189eb3bb6838c087ceeadeb8559d4cc62486e54e35e10ca9ab/68747470733a2f2f636f6465636f762e696f2f67682f566f6e6167652f766f6e6167652d7068702d6a77742f67726170682f62616467652e7376673f746f6b656e3d3657494d475a534f554c)](https://codecov.io/gh/Vonage/vonage-php-jwt)

[![Vonage logo](vonage_logo.png)](vonage_logo.png)

*This library requires a minimum PHP version of 8.1*

This is the PHP library for generating JWTs to use Vonage's API. To use this, you'll need a Vonage account. Sign up [for free at vonage.com/dashboard](https://dashboard.nexmo.com/sign-up?utm_source=DEV_REL&utm_medium=github&utm_campaign=php-client-library).

- [Installation](#installation)
- [Usage](#usage)
- [Examples](#examples)
- [Contributing](#contributing)

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

[](#installation)

To use the client library you'll need to have [created a Vonage account](https://dashboard.nexmo.com/sign-up?utm_source=DEV_REL&utm_medium=github&utm_campaign=php-client-library).

To install the PHP client library to your project, we recommend using [Composer](https://getcomposer.org/).

```
composer require vonage/jwt
```

> You don't need to clone this repository to use this library in your own projects. Use Composer to install it from Packagist.

If you're new to Composer, here are some resources that you may find useful:

- [Composer's Getting Started page](https://getcomposer.org/doc/00-intro.md) from Composer project's documentation.
- [A Beginner's Guide to Composer](https://scotch.io/tutorials/a-beginners-guide-to-composer) from the good people at ScotchBox.

Usage
-----

[](#usage)

If you're using Composer, make sure the autoloader is included in your project's bootstrap file:

```
require_once "vendor/autoload.php";
```

Create a Token Generator with the Application ID and Private Key of the Vonage Application you want to access:

```
$generator = new Vonage\JWT\TokenGenerator('d70425f2-1599-4e4c-81c4-cffc66e49a12', file_get_contents('/path/to/private.key'));
```

You can then retrieve a generated JWT token by calling the `generate()` method on the Token Generator:

```
$token = $generator->generate();
```

This will return a string token that can be used for Bearer Authentication to Vonage APIs that require JWTs.

Examples
--------

[](#examples)

### Generating a token with a specific Time To Live

[](#generating-a-token-with-a-specific-time-to-live)

By default, Vonage JWT tokens are generated with an Time To Live, or TTL, of 15 minutes after generation. In cases where the token lifetime should be different, you can override this setting by calling the `setTTL()` method on the Token Generator and passing the length of seconds that the token should be valid for

```
$generator->setTTL(30 * 60); // Set expiration to 30 minutes after token creation
```

### Setting ACLs

[](#setting-acls)

Vonage JWTs will default to full access to all of the paths for an application, but this may not be desirable for cases where clients may need restricted access. You can specify the paths that a JWT token is valid for by using the `setPaths()` or `addPath()` methods to set the path information in bulk, or add individual paths in a more fluent interface.

```
// Set paths in bulk
$generator->setPaths([
    '/*/users/**',
    '/*/conversations/**'
]);

// Set paths individually
$generator->addPath('/*/users/**');
$generator->addPath('/*/conversations/**');
```

For more information on assigning ACL information, please see [How to generate JWTs on the Vonage Developer Platform](https://developer.nexmo.com/conversation/guides/jwt-acl)

Contributing
------------

[](#contributing)

This library is actively developed and we love to hear from you! Please feel free to [create an issue](https://github.com/Vonage/vonage-php-jwt/issues) or [open a pull request](https://github.com/Vonage/vonage-php-jwt/pulls) with your questions, comments, suggestions and feedback.

###  Health Score

63

—

FairBetter than 99% of packages

Maintenance87

Actively maintained with recent releases

Popularity55

Moderate usage in the ecosystem

Community22

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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

Recently: every ~366 days

Total

8

Last Release

63d ago

PHP version history (4 changes)0.2.0PHP ^7.2|^8.0

0.4.0PHP ~8.0 || ~8.1 || ~8.2

0.5.0PHP ~8.1 || ~8.2 || ~8.3

0.6.0PHP ~8.1 || ~8.2 || ~8.3 || ~8.4 || ~8.5

### Community

Maintainers

![](https://www.gravatar.com/avatar/8c2583b67d4e1a4ade23b6ce271980d18bf3facb4ea3f0610fded770f380d17d?d=identicon)[dragonmantank](/maintainers/dragonmantank)

![](https://avatars.githubusercontent.com/u/2683897?v=4)[Vonage](/maintainers/Vonage)[@Vonage](https://github.com/Vonage)

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

---

Top Contributors

[![SecondeJK](https://avatars.githubusercontent.com/u/17067659?v=4)](https://github.com/SecondeJK "SecondeJK (17 commits)")[![dragonmantank](https://avatars.githubusercontent.com/u/108948?v=4)](https://github.com/dragonmantank "dragonmantank (16 commits)")[![ercsctt](https://avatars.githubusercontent.com/u/6897798?v=4)](https://github.com/ercsctt "ercsctt (1 commits)")[![erickskrauch](https://avatars.githubusercontent.com/u/4787256?v=4)](https://github.com/erickskrauch "erickskrauch (1 commits)")[![mheap](https://avatars.githubusercontent.com/u/59130?v=4)](https://github.com/mheap "mheap (1 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/vonage-jwt/health.svg)

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

###  Alternatives

[tymon/jwt-auth

JSON Web Token Authentication for Laravel and Lumen

11.5k49.1M350](/packages/tymon-jwt-auth)[directorytree/ldaprecord-laravel

LDAP Authentication &amp; Management for Laravel.

5682.0M15](/packages/directorytree-ldaprecord-laravel)[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)[amocrm/amocrm-api-library

amoCRM API Client

182728.5k6](/packages/amocrm-amocrm-api-library)[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)
