josegarcia/jwt-auth

A simple JWT authentication library

1.1.1 2024-03-11 01:03 UTC

This package is auto-updated.

Last update: 2024-05-11 01:23:46 UTC


README

  • This package is a simple JWT (JSON Web Token) library for PHP. It is easy to use and works with any PHP framework, library, or application.

Description

  • This package is a simple JWT (JSON Web Token) library for PHP. It is easy to use and works with any PHP framework, library, or application.

Features

  • No configuration required.
  • No dependencies.
  • Lightweight.
  • Easy to use.
  • Works with PHP 7.4 and above.
  • Works with any PHP framework, library, or application.

Installation

composer require josegarcia/jwt-auth

Usage

<?php
require_once 'vendor/autoload.php';

use Garcia\JWT;

$jwt = new JWT('secret');

$payload = [
    'user_id' => 1,
    'username ' => 'johndoe',
    'email' => 'testing@testing.com',
    'role' => 'admin'
];

$token = $jwt->encode($payload);

echo "$token \n\n";

$decoded = $jwt->decode($token);

var_dump($decoded);

License

  • This package is open-sourced software licensed under the MIT license.

Author