承接 zen0x7/tokenizer 相关项目开发

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

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

zen0x7/tokenizer

最新稳定版本:1.0.2

Composer 安装命令:

composer require zen0x7/tokenizer

包简介

PHP SDK for Service Framework authentication and token generation.

README 文档

README

A high-performance PHP SDK for generating authenticated and encrypted JSON Web Tokens (JWT) for the Service Framework cluster.

Features

  • JWE/JWS Support: Fully compatible with the C++ implementation (AES-256-GCM + HMAC-SHA256).
  • Fluent Builder: Easy token construction with a human-readable interface.
  • Grants & Wildcards: Full support for resource-based grants (channels:*, cache:user.*, system:admin).
  • Laravel Ready: Easily integrable into any PHP 8.1+ project or framework.

Installation

Install via Composer:

composer require zen0x7/tokenizer

Usage

Generating a Token

use Zen0x7\Tokenizer\TokenBuilder;

$builder = TokenBuilder::create()
    ->withSubject('user_123')
    ->withDuration(3600) // 1 hour
    ->withSystemPermissions(['admin', 'broadcast'])
    ->withChannelPermissions('chat.general', ['read', 'write'])
    ->withChannelPermissions('private.*', ['read'])
    ->withCachePermissions('user:profile:*', ['read', 'write', 'delete'])
    ->withClaim('custom_field', 'custom_value');

$token = $builder->build(
    signatureKey: 'base64:your_signature_key_here',
    encryptionKey: 'base64:your_encryption_key_here'
);

echo "Authorization: Bearer " . $token;

Key Formats

The SDK supports both raw binary keys and base64-encoded keys (prefixed with base64:).

// Example with base64 keys
$signatureKey = 'base64:c2VjcmV0X3NpZ25hdHVyZV9rZXlfZm9yX2V4YW1wbGVfdXNhZ2U=';
$encryptionKey = 'base64:YWVzXzI1Nl9nY21fZXhhbXBsZV9rZXlfMzJfYnl0ZXM=';

Security

This SDK implements:

  1. JWS (JSON Web Signature): HMAC-SHA256 protecting the entire token.
  2. JWE (JSON Web Encryption): AES-256-GCM encrypting the payload.
  3. Base64Url: Standard URL-safe encoding for JWT parts.

License

MIT

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固