承接 phpnomad/firebase-jwt-integration 相关项目开发

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

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

phpnomad/firebase-jwt-integration

最新稳定版本:1.0.0

Composer 安装命令:

composer require phpnomad/firebase-jwt-integration

包简介

README 文档

README

Latest Version Total Downloads PHP Version License

Integrates the firebase/php-jwt library with phpnomad/auth's JwtStrategy interface. It provides a single concrete strategy that encodes payloads into HS256-signed JSON Web Tokens and decodes them back into arrays, translating firebase/php-jwt's exception types into PHPNomad\Auth\Exceptions\JwtException so the rest of your application only has to catch one thing.

Installation

composer require phpnomad/firebase-jwt-integration

What This Provides

  • A FirebaseJwt strategy class that implements PHPNomad\Auth\Interfaces\JwtStrategy using firebase/php-jwt, with HS256 for both encoding and verification.
  • Exception translation that maps ExpiredException, SignatureInvalidException, BeforeValidException, and the standard PHP value errors into PHPNomad\Auth\Exceptions\JwtException with descriptive messages.

Requirements

  • phpnomad/auth ^1.0 for the JwtStrategy interface and its JwtException type.
  • firebase/php-jwt ^6.10 as the underlying JWT library.

Usage

Bind FirebaseJwt to the JwtStrategy interface inside one of your bootstrapper initializers. Any service that depends on JwtStrategy will then receive this implementation without knowing which library is wired in behind it.

<?php

namespace MyApp\Strategies;

use PHPNomad\Auth\Interfaces\JwtStrategy;
use PHPNomad\JWT\Firebase\Integration\Strategies\FirebaseJwt;
use PHPNomad\Loader\Interfaces\HasClassDefinitions;

final class JwtInitializer implements HasClassDefinitions
{
    public function getClassDefinitions(): array
    {
        return [
            FirebaseJwt::class => JwtStrategy::class,
        ];
    }
}

With that binding in place, a service can take JwtStrategy as a constructor dependency and call $jwt->encode($payload, $secret) or $jwt->decode($token, $secret) without ever referencing FirebaseJwt directly.

Documentation

See the bootstrapping and strategy binding guides at phpnomad.com. For details on the underlying library, configuration options, and supported algorithms, see firebase/php-jwt.

License

Released under the MIT License. See LICENSE.txt.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-12-18