定制 matiasnamendola/slimpower-jwt 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

matiasnamendola/slimpower-jwt

Composer 安装命令:

composer require matiasnamendola/slimpower-jwt

包简介

A simple library to encode and decode JSON Web Tokens (JWT) in PHP, conforming to RFC 7519

README 文档

README

Latest version Total Downloads

Latest Stable Version Latest Unstable Version Total Downloads Monthly Downloads Daily Downloads composer.lock available

A simple library to encode and decode JSON Web Tokens (JWT) in PHP, conforming to RFC 7519.

Installation

In terminal, use composer to manage your dependencies and download 'Slimpower JWT':

composer require matiasnamendola/slimpower-jwt

Or you can add use this as your composer.json:

{
    "require": {
        "matiasnamendola/slimpower-jwt": "dev-master"
    }
}

Example

<?php

use \SlimPower\JWT\JWT;

$key = "secret";

$token = array(
    "iss" => "http://example.org",
    "aud" => "http://example.com",
    "iat" => 1481113105,
    "nbf" => 1481000000
);

/**
 * IMPORTANT:
 * You must specify supported algorithms for your application. See
 * https://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-40
 * for a list of spec-compliant algorithms.
 */
$jwt = JWT::encode($token, $key);
$decoded = JWT::decode($jwt, $key, array('HS256'));

print_r($decoded);

/*
 NOTE: This will now be an object instead of an associative array. To get
 an associative array, you will need to cast it as such:
*/

$decoded_array = (array) $decoded;

/**
 * You can add a leeway to account for when there is a clock skew times between
 * the signing and verifying servers. It is recommended that this leeway should
 * not be bigger than a few minutes.
 *
 * Source: http://self-issued.info/docs/draft-ietf-oauth-json-web-token.html#nbfDef
 */
JWT::$leeway = 60; // $leeway in seconds
$decoded = JWT::decode($jwt, $key, array('HS256'));

?>

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-12-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固