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)318.4k↑85.7%2[2 PRs](https://github.com/bolivir/laravel-doctrine-sanctum/pulls)MITPHPPHP ^8.2CI passing

Since Feb 25Pushed 5mo 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 yesterday

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

48

—

FairBetter than 93% of packages

Maintenance58

Moderate activity, may be stable

Popularity31

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity74

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

494d 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://avatars.githubusercontent.com/u/15746633?v=4)[Ricardo Mosselman](/maintainers/Bolivir)[@bolivir](https://github.com/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

[unopim/unopim

UnoPim Laravel PIM

10.5k2.4k](/packages/unopim-unopim)[hasinhayder/tyro

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

6783.6k6](/packages/hasinhayder-tyro)[daniel-de-wit/lighthouse-sanctum

Laravel Sanctum support for Laravel Lighthouse.

61124.6k](/packages/daniel-de-wit-lighthouse-sanctum)[fleetbase/core-api

Core Framework and Resources for Fleetbase API

1235.9k20](/packages/fleetbase-core-api)[albetnov/sanctum-refresh

This package extends sanctum ability to be able to provide refresh token as well

211.7k](/packages/albetnov-sanctum-refresh)

PHPackages © 2026

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