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
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:diffafter the creation of your model and metadata (xml). Then execute the migration withmigrations: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.
统计信息
- 总下载量: 16.07k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-04-03