定制 damirka/yii2-jwt 二次开发

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

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

damirka/yii2-jwt

最新稳定版本:v0.2.1

Composer 安装命令:

composer require damirka/yii2-jwt

包简介

Trait for easier JWT integration

关键字:

README 文档

README

JWT implementation for Yii2 Authorization process

For details see JWT official website.

Installation

To install (only master is available now) run:

 composer require "damirka/yii2-jwt:v0.2.1" 

Or add this line to require section of composer.json:

 "damirka/yii2-jwt": "v0.2.1" 

Usage

There is only one trait - UserTrait - which gives you 5 methods for authorization and JWT-management in User model

Set up:

In controller:

<?php // ... use yii\filters\auth\HttpBearerAuth; class BearerAuthController extends \yii\rest\ActiveController { public function behaviors() { return array_merge(parent::behaviors(), [ 'bearerAuth' => [ 'class' => HttpBearerAuth::className() ] ]); } }

In User model:

<?php // ... use yii\db\ActiveRecord; use yii\web\IdentityInterface class User extends ActiveRecord implements IdentityInterface { // Use the trait in your User model use \damirka\JWT\UserTrait; // Override this method protected static function getSecretKey() { return 'someSecretKey'; } // And this one if you wish protected static function getHeaderToken() { return []; } // ... }

统计信息

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

GitHub 信息

  • Stars: 65
  • Watchers: 4
  • Forks: 20
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固