josegarcia/jwt-auth
最新稳定版本:1.1.1
Composer 安装命令:
composer require josegarcia/jwt-auth
包简介
A simple JWT authentication library
README 文档
README
Requirements
- PHP 7.4 or higher
- Composer
JWT
- A lightweight and straightforward PHP library for working with JSON Web Tokens (JWT). Compatible with any PHP framework, application, or library.
Description
- This library offers an easy-to-use solution for implementing JWT in PHP projects. It integrates smoothly with any PHP-based setup, whether you're using a framework or building a standalone 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); try { $decoded = $jwt->decode($token); var_dump($decoded); } catch (\Exception $e) { echo "Token invalid: " . $e->getMessage(); }
License
- This package is open-sourced software licensed under the MIT license.
Author
统计信息
- 总下载量: 34
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-03-04