PHPackages                             setiawanhu/sanctum-auth - 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. setiawanhu/sanctum-auth

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

setiawanhu/sanctum-auth
=======================

Laravel package for generating user authentication feature using Laravel Sanctum

2.0.0(3y ago)132.8k3MITPHPPHP ^8.0.2

Since May 19Pushed 2y ago1 watchersCompare

[ Source](https://github.com/setiawanhu/sanctum-auth)[ Packagist](https://packagist.org/packages/setiawanhu/sanctum-auth)[ RSS](/packages/setiawanhu-sanctum-auth/feed)WikiDiscussions master Synced today

READMEChangelog (9)Dependencies (3)Versions (12)Used By (0)

Laravel sanctum-auth Package
============================

[](#laravel-sanctum-auth-package)

[![Latest Stable Version](https://camo.githubusercontent.com/7ca5d6dce34d735cf550cbd2aa65e5e456f39d0ac421cea5d6b8a3df13674688/68747470733a2f2f706f7365722e707567782e6f72672f736574696177616e68752f73616e6374756d2d617574682f76)](//packagist.org/packages/setiawanhu/sanctum-auth) [![Total Downloads](https://camo.githubusercontent.com/b607ee86bf0e8e4d03635e32f056202796f98709ad2aa4a92925d777e30abb21/68747470733a2f2f706f7365722e707567782e6f72672f736574696177616e68752f73616e6374756d2d617574682f646f776e6c6f616473)](//packagist.org/packages/setiawanhu/sanctum-auth) [![License](https://camo.githubusercontent.com/c0cdcff063c0b112d7817c15a1b710e7c8447b82d095468eabafc74b99cd7d54/68747470733a2f2f706f7365722e707567782e6f72672f736574696177616e68752f73616e6374756d2d617574682f6c6963656e7365)](//packagist.org/packages/setiawanhu/sanctum-auth)

Laravel package for generating user authentication feature using Laravel Sanctum

For information &amp; usage about Laravel Sanctum, please refer to [Laravel Sanctum documentation](https://laravel.com/docs/7.x/sanctum).

Get Started
-----------

[](#get-started)

Include the Sanctum Auth package by calling this composer command in project root:

```
composer require setiawanhu/sanctum-auth

```

**Note**: This package is only supporting Laravel 9

Usage
-----

[](#usage)

We may publish the Sanctum Auth migration files using `vendor:publish` artisan command:

```
php artisan vendor:publish --provider="Hu\Auth\SanctumAuthServiceProvider"

```

This command will copy the user role's migration file to /database/migrations folder and will publish the `laravel/sanctum` configuration and migration files.

Then, run Sanctum Auth artisan command by running:

```
php artisan sanctum-auth:controller [{type} --force]

```

This command will generate the auth routing out of the box.

Note:

1. The `type` argument is optional with default value are `token`. The controller will be generated based on given argument value. Available types are `token` and `spa`.
2. The `--force` option is optional. We may use it for ignoring existing controller.

Then, make `User` model to extend `AuthModel` class:

```
use Hu\Auth\AuthModel;

class User extends AuthModel {
    //...
}
```

Using Roles
-----------

[](#using-roles)

if the `User` has roles, we may use the `HasRole` trait to the `User` model:

```
use Hu\Auth\HasRole;

class User extends AuthModel {

    use HasRole;

    //...
}
```

Then, we add a new field to the users table:

```
//...

Schema::create('users', function (Blueprint $table) {

    //...

    $table->unsignedBigInteger('role_id')

    //...

}

//...
```

Then, run the database migration command:

```
php artisan migrate

```

Dig Deeper
----------

[](#dig-deeper)

Please check [wiki](https://github.com/setiawanhu/sanctum-auth/wiki) for more details about sanctum-auth usage

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~127 days

Recently: every ~283 days

Total

11

Last Release

908d ago

Major Versions

1.3.0 → 2.0.02022-08-29

1.x-dev → 2.x-dev2023-11-15

PHP version history (4 changes)1.0.0PHP ^7.2.5

2.0.0PHP ^8.0.2

1.4.0PHP ^7.2|^8.0

2.x-devPHP ^8.1

### Community

Maintainers

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

---

Top Contributors

[![setiawanhu](https://avatars.githubusercontent.com/u/27731265?v=4)](https://github.com/setiawanhu "setiawanhu (36 commits)")

---

Tags

laravellaravel-sanctumsanctumlaravelauthsanctum

### Embed Badge

![Health badge](/badges/setiawanhu-sanctum-auth/health.svg)

```
[![Health](https://phpackages.com/badges/setiawanhu-sanctum-auth/health.svg)](https://phpackages.com/packages/setiawanhu-sanctum-auth)
```

###  Alternatives

[hasinhayder/tyro

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

6712.1k2](/packages/hasinhayder-tyro)

PHPackages © 2026

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