PHPackages                             bolivir/laravel-doctrine-sanctum - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. bolivir/laravel-doctrine-sanctum

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

bolivir/laravel-doctrine-sanctum
================================

Laravel doctrine integration for the official laravel-sanctum package

5.0.0(1y ago)316.8k↓33.3%2[2 PRs](https://github.com/bolivir/laravel-doctrine-sanctum/pulls)MITPHPPHP ^8.2CI passing

Since Feb 25Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/bolivir/laravel-doctrine-sanctum)[ Packagist](https://packagist.org/packages/bolivir/laravel-doctrine-sanctum)[ RSS](/packages/bolivir-laravel-doctrine-sanctum/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (9)Versions (17)Used By (0)

Laravel Doctrine Sanctum
========================

[](#laravel-doctrine-sanctum)

[![example branch parameter](https://github.com/bolivir/laravel-doctrine-sanctum/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/bolivir/laravel-doctrine-sanctum/actions/workflows/ci.yml/badge.svg?branch=master)

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

Versions
--------

[](#versions)

VersionSupported Sanctum VersionSupported 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.0Installation
============

[](#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
=====================

[](#configuration--setup)

### Creating the Access Token Model

[](#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

[](#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

[](#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
------------

[](#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.
-------------------------------------

[](#see-the-wiki-for-more-detailed-steps)

###  Health Score

49

—

FairBetter than 95% of packages

Maintenance64

Regular maintenance activity

Popularity30

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor1

Top contributor holds 53.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~132 days

Recently: every ~83 days

Total

12

Last Release

442d ago

Major Versions

v1.1.1 → v2.0.0-rc.12023-12-07

v2.1.0 → v3.0.02024-06-28

v3.0.0 → v4.0.02024-08-21

v4.0.0 → 5.0.02025-02-24

PHP version history (4 changes)1.0.0-alpha.1PHP ^7.4

v1.0.0-alpha.2PHP ^7.4|^8.0

v2.0.0-rc.1PHP ^8.0

v3.0.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/c36635aa927142353422fa5b04abccafd8d48cf62e8e6b69a52924c5b20ee2f0?d=identicon)[Bolivir](/maintainers/Bolivir)

---

Top Contributors

[![bolivir](https://avatars.githubusercontent.com/u/15746633?v=4)](https://github.com/bolivir "bolivir (28 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (17 commits)")[![JeroenBoesten](https://avatars.githubusercontent.com/u/5631345?v=4)](https://github.com/JeroenBoesten "JeroenBoesten (4 commits)")[![jochemfuchs](https://avatars.githubusercontent.com/u/4397250?v=4)](https://github.com/jochemfuchs "jochemfuchs (2 commits)")[![jpoelmans](https://avatars.githubusercontent.com/u/2128927?v=4)](https://github.com/jpoelmans "jpoelmans (1 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/bolivir-laravel-doctrine-sanctum/health.svg)

```
[![Health](https://phpackages.com/badges/bolivir-laravel-doctrine-sanctum/health.svg)](https://phpackages.com/packages/bolivir-laravel-doctrine-sanctum)
```

###  Alternatives

[hasinhayder/tyro

Tyro - The ultimate Authentication, Authorization, and Role &amp; Privilege Management solution for Laravel 12 &amp; 13

6712.1k2](/packages/hasinhayder-tyro)[ikechukwukalu/requirepin

A laravel package for pin confirmation and validation before processing requests to a specified route

24910.5k1](/packages/ikechukwukalu-requirepin)[daniel-de-wit/lighthouse-sanctum

Laravel Sanctum support for Laravel Lighthouse.

61115.9k](/packages/daniel-de-wit-lighthouse-sanctum)[mohamedgaber-intake40/sanctum-refresh-token

add refresh token feature to laravel sanctum official package

4573.9k](/packages/mohamedgaber-intake40-sanctum-refresh-token)[saeven/zf3-circlical-user

Complete user entity, rights, and access module for Laminas

3718.7k](/packages/saeven-zf3-circlical-user)[devtical/filament-sanctum

Laravel Sanctum integration for Filament 4

533.0k](/packages/devtical-filament-sanctum)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
