简单的jwt类

1.0.1 2020-06-20 14:03 UTC

This package is auto-updated.

Last update: 2024-09-20 12:14:36 UTC


README

Scrutinizer Code Quality GitHub last commit GitHub repository size Build Status Code Intelligence Status

该项目仅是一个简单的JWT类,可以添加到您的项目中,并可以通过常量进行配置。

摘要

先决条件

  • PHP >= 7.2
  • Composer

安装

您可以使用此命令克隆项目

  • 克隆仓库
git clone https://github.com/GuilhermeTome/jwt
  • 在您的项目中安装
composer require guilhermetome/jwt

如何使用

  • 只需遵循文档。

声明jwt密钥

  • 在您的应用程序中,您需要创建一个如下所示的常量
<?php

// the key of the application
define('JWT_SECRET', 'mysecret');

// the hash of the jwt
define('JWT_HASH', 'sha256');

// the alg to put in header
define('JWT_ALG', 'HS256');

生成jwt密钥

  • @param array
  • @return string
<?php

use GuilhermeTome\Jwt;

echo Jwt::encode([
    'user' => 'Guilherme',
    'email' => 'email@gmail.com',
    'pass' => 'MyPassword'
]);

解码jwt密钥

  • @param string
  • @return array|false
<?php

use GuilhermeTome\Jwt;

echo Jwt::decode($key);

贡献

欢迎提交拉取请求。对于重大更改,请首先打开一个问题来讨论您希望进行哪些更改。请确保适当更新测试。

许可证

该项目受MIT许可证的许可 - 请参阅MIT许可证以获取更多详细信息