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

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

nexmo/jwt
=========

A standalone package for creating JWTs for Nexmo/Vonage APIs

0.1.0(5y ago)0226[3 PRs](https://github.com/Nexmo/nexmo-jwt-php/pulls)MITPHP

Since Jul 21Pushed 3mo ago12 watchersCompare

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

READMEChangelogDependencies (5)Versions (3)Used By (0)

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://camo.githubusercontent.com/c263f5f435071f71ab539e6477fe25ed1d4a65117789846e0c9b29df660032d0/68747470733a2f2f6170692e7472617669732d63692e6f72672f4e65786d6f2f6e65786d6f2d6a77742d7068702e7376673f6272616e63683d6d61696e)](https://travis-ci.org/Nexmo/nexmo-jwt-php)[![Latest Stable Version](https://camo.githubusercontent.com/719f57cfd67f8c9e1032f979d63b2287653b6990ee0c660b3e6c8de8e021edec/68747470733a2f2f706f7365722e707567782e6f72672f6e65786d6f2f6a77742f762f737461626c65)](https://packagist.org/packages/nexmo/jwt)[![MIT licensed](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](./LICENSE.txt)[![codecov](https://camo.githubusercontent.com/59b275282c4c43e3a97937328887606189d7f725dc5d90d307f795c852f0a8ca/68747470733a2f2f636f6465636f762e696f2f67682f4e65786d6f2f6e65786d6f2d6a77742f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/Nexmo/nexmo-jwt)

[![Nexmo is now known as Vonage](https://camo.githubusercontent.com/ccd17f652c73446c29e6b56a04f6b5c66ad6aaa85abd041db374e5d2a6b55d3f/68747470733a2f2f646576656c6f7065722e6e65786d6f2e636f6d2f6173736574732f696d616765732f566f6e6167655f4e65786d6f2e737667)](https://camo.githubusercontent.com/ccd17f652c73446c29e6b56a04f6b5c66ad6aaa85abd041db374e5d2a6b55d3f/68747470733a2f2f646576656c6f7065722e6e65786d6f2e636f6d2f6173736574732f696d616765732f566f6e6167655f4e65786d6f2e737667)

*This library requires a minimum PHP version of 7.1*

This is the PHP library for generating JWTS to use Nexmo's API. To use this, you'll need a Nexmo account. Sign up [for free at nexmo.com](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 Nexmo 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 nexmo/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 Nexmo Application you want to access:

```
$generator = new Nexmo\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 Nexmo 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, Nexmo 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)

Nexmo 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 Nexmo 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/Nexmo/nexmo-jwt-php/issues) or [open a pull request](https://github.com/Nexmo/nexmo-jwt-php/pulls) with your questions, comments, suggestions and feedback.

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance53

Moderate activity, may be stable

Popularity9

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 88.9% 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

2127d ago

### 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

[![dragonmantank](https://avatars.githubusercontent.com/u/108948?v=4)](https://github.com/dragonmantank "dragonmantank (8 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/nexmo-jwt/health.svg)

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

###  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)[directorytree/ldaprecord-laravel

LDAP Authentication &amp; Management for Laravel.

5682.0M15](/packages/directorytree-ldaprecord-laravel)[vonage/jwt

A standalone package for creating JWTs for Vonage APIs

424.1M4](/packages/vonage-jwt)[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)

PHPackages © 2026

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