承接 sergeymitr/simple-php-jwt 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

sergeymitr/simple-php-jwt

Composer 安装命令:

composer require sergeymitr/simple-php-jwt

包简介

Simple JWT Authentication using PHP

README 文档

README

The library serves a single purpose: making JWT easier to work with.

Requirements

  • PHP 7.4 or higher.

Installation

Run this command to install the library via Composer:

composer require sergeymitr/simple-php-jwt

Usage

Creating and Encoding the Token

Use Token::create() factory method to create a new token:

use Sergeymitr\SimpleJWT\Token;

$token = Token::create();

The token doesn't hold any data, so we'll need to fill that out:

$token->setIssuer('Sergeymitr\SimpleJWT')
    ->setSubject('Test Sample')
    ->setAudience('PHPUnit')
    ->setExpiration(new \DateTime('2020-02-02'))
    ->setNotBefore(new \DateTime('2020-01-01'))
    ->setIssuedAt(new DateTime('2020-01-15'))
    ->setID('sample-id');

All the data is optional, you only fill out what you need. These methods define the claim names described by RFC 7519.

You can also add custom values to your token:

$token->setCustomPayload('key', 'value');

To encode the token you will need use the Token object, and a secret string to encode it with.

use Sergeymitr\SimpleJWT\Encoder;

$encoded_token = Encoder::do($token, 'secret');

The $encoded_token will contain a string representation of the encoded and encrypted token.

Decoding the Token

To decode the token you'll need the string representation of the token, and the secret string you encoded it with:

use Sergeymitr\SimpleJWT\Decoder;

$token = Decoder::do($encodedToken, 'secret');

The Token object provides a number of "getter" methods you can use to retrieve the values, which you can review in the interface TokenInterface.

统计信息

  • 总下载量: 11
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0-or-later
  • 更新时间: 2021-03-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固