Skip to content

Guide · Open source

How to use jwt-auth: install it in Laravel or Lumen

Updated · written with AI from the project's own documentation and checked against our catalogue data

jwt-auth is an open-source PHP package that adds JSON Web Token (JWT) login support to Laravel and Lumen applications. It is aimed at developers building APIs or apps that need token-based authentication in these frameworks. This guide explains what the package does, what you need before installing it, how to install it with Composer, and when a different tool may suit you better.

jwt-authtymondesigns/jwt-auth · ★ 11.5k · MIT

Quick start

  1. 1Confirm prerequisites. Make sure PHP, Composer and a Laravel or Lumen project are available.
  2. 2Open your project root. Change into the directory that contains your Laravel or Lumen application.
  3. 3Install the package. Run composer require tymon/jwt-auth to add the package to your project.
  4. 4Read the documentation. Follow the configuration and usage guide at jwt-auth.com to set up token login in your app.

What jwt-auth does

A JWT is a signed token that a server gives a user after login. The user sends that token back with later requests to prove who they are. jwt-auth handles this token-based login flow inside a Laravel or Lumen application.

Check the prerequisites before you install

The package works only with Laravel and Lumen, so it is not a fit for non-PHP projects. Setup assumes you are already comfortable with the framework's authentication concepts, so beginners with no Laravel experience will find it harder to follow.

  • PHP
  • Composer
  • An existing Laravel or Lumen project

Install jwt-auth with Composer

jwt-auth is distributed through Packagist, so you install it with the package manager Composer. Run the command below from the root of your Laravel or Lumen project. The package is listed on Packagist as tymon/jwt-auth.

composer require tymon/jwt-auth

Next steps: configuration and usage

The README points to the full documentation at jwt-auth.com for configuration and usage details. The source material used for this page covers installation only, so check the official documentation for the steps that follow installation, such as setting up your user model and issuing tokens.

  • Read the documentation at https://jwt-auth.com
  • Confirm your Laravel or Lumen version works with the package before upgrading

Report security issues privately

The maintainer asks that security-related issues be emailed to tymon148@gmail.com rather than reported in the public issue tracker.

What people use it for

  • Adding token-based login to a Laravel API used by a mobile or single-page app
  • Adding JWT authentication to a Lumen service that needs to verify users
  • Using an MIT-licensed auth package distributed through Packagist in a team project

Frequently asked questions

Is jwt-auth free to use?

jwt-auth is released under the MIT licence, as stated in its README. The licence text is included in the project. Check the repository's licence file before you rely on it for a commercial product.

What do I need before installing jwt-auth?

You need PHP, Composer and a Laravel or Lumen project. The package only works with these PHP frameworks.

How do I install jwt-auth?

Run composer require tymon/jwt-auth from your project root. The package is distributed through Packagist.

Does jwt-auth work outside Laravel?

No. The package is built for Laravel and Lumen, so it is not suitable for non-PHP projects or PHP projects using other frameworks.

What are alternatives to jwt-auth?

Comparable projects listed for this item include laravel/sanctum, laravel/passport and php-open-source-saver/jwt-auth. Compare them on how each handles tokens and your project's needs.

Where can I get help with jwt-auth?

The README links to the documentation at jwt-auth.com. For security issues, the maintainer asks you to email tymon148@gmail.com instead of opening a public issue.

New agent skills, repos and AI tools — every week

The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.

Our verdict

Use jwt-auth if you build APIs or apps in Laravel or Lumen and want JWT login from an MIT-licensed Packagist package. Pick something else if your project is not in PHP, if you have no Laravel experience yet, or if you want a hosted login service instead of code in your own app.

Install options & downloads