定制 bolivir/laravel-doctrine-sanctum 二次开发

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

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

bolivir/laravel-doctrine-sanctum

最新稳定版本:5.0.0

Composer 安装命令:

composer require bolivir/laravel-doctrine-sanctum

包简介

Laravel doctrine integration for the official laravel-sanctum package

README 文档

README

example branch parameter

The original Laravel Sanctum works via eloquent, this package makes it work with laravel-doctrine/orm package (https://github.com/laravel-doctrine/orm)

Versions

Version Supported Sanctum Version Supported Laravel-Doctrine ORM Version
~1.0 ^2.0 ^1.0
~2.0 ^2.0 ^2.0
~3.0 ^3.0 ^2.0
~4.0 ^4.0 ^2.0
~5.0 ^4.0 ^3.0

Installation

Start by installing the package with the following command:

composer require "bolivir/laravel-doctrine-sanctum"

To publish the config use:

php artisan vendor:publish --tag="config" --provider="Bolivir\LaravelDoctrineSanctum\LaravelDoctrineSanctumProvider"

Configuration / Setup

Creating the Access Token Model

Start by creating your accessTokenModel, and implement the interface IAccessToken.

class AccessToken implements IAccessToken
{
    use TAccessToken;
}

You can use the Trait TAccessToken or just implement the interface by your self.

class AccessToken implements IAccessToken
{
      protected string $id;
    
      protected string $name;
    
      protected string $token;
        
      .......
      .......
}

Updating the UserModel

Your user model should implement the interface ISanctumUser. You dont need to implement the Authenticable on your user model directly, it is required inside the ISanctumUser Now you can choose to use the trait TAccessToken or implement the interface yourself.

Creating the database table

Laravel sanctum uses the database to store the access tokens. There are multiple options available to generate the database table sql

  • If you are using laravel migrations, run migrations:diff after the creation of your model and metadata (xml). Then execute the migration with migrations:migrate

Ready to use

Implement your login logic and start creating access tokens on succesfull login.

class MyLoginService
{       
      .......
      .......
      public function login() 
      {
        ....
        ....
        $accessToken = $this->tokenRepository->createToken($user, 'tokenName');
      }
}

See the WIKI for more detailed steps.

https://github.com/bolivir/laravel-doctrine-sanctum/wiki

统计信息

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

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-04-03