PHPackages                             devraeph/laravel-xtoken - 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. devraeph/laravel-xtoken

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

devraeph/laravel-xtoken
=======================

This Package creates a JWTToken for the Application and provides a middelware for Auth

1.5.4(3y ago)01.1kAGPL-3.0-or-laterPHP

Since Feb 6Pushed 3y ago1 watchersCompare

[ Source](https://github.com/DevRaeph/laravel-xtoken)[ Packagist](https://packagist.org/packages/devraeph/laravel-xtoken)[ RSS](/packages/devraeph-laravel-xtoken/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (1)Dependencies (2)Versions (10)Used By (0)

[![Social Card of laravel-xtoken](https://camo.githubusercontent.com/87fc577a75e2f236b81fb520acf87f0f7ed6e25aed90007e253dc3e283954f56/68747470733a2f2f692e706f7374696d672e63632f3863703747635a372f556e62656e616e6e742d312e6a7067)](https://camo.githubusercontent.com/87fc577a75e2f236b81fb520acf87f0f7ed6e25aed90007e253dc3e283954f56/68747470733a2f2f692e706f7374696d672e63632f3863703747635a372f556e62656e616e6e742d312e6a7067)

DevRaeph / laravel-xtoken
=========================

[](#devraeph--laravel-xtoken)

[![Total Downloads](https://camo.githubusercontent.com/f40b09092fec6661ae5b798919e1718b2fc7025e5b7c7e63dbed88dfc0dc6d34/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f64657672616570682f6c61726176656c2d78746f6b656e)](https://packagist.org/packages/devraeph/laravel-xtoken)[![Latest Stable Version](https://camo.githubusercontent.com/2183d7930f3060cadd6defcecf2b324b80c7416fa7438bf10a9d0cf238ec21a8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f64657672616570682f6c61726176656c2d78746f6b656e)](https://packagist.org/packages/devraeph/laravel-xtoken)[![Issues](https://camo.githubusercontent.com/cb2926c22b4ddf40ed909c64845daf4be9e550cd4f29e10f0fa6eccc19c56be8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f44657652616570682f6c61726176656c2d78746f6b656e)](https://github.com/DevRaeph/laravel-xtoken/issues)

A simple package with which you can issue JWT tokens and also verify them. Usable for multiple models, thanks to existing trait.

Installation
------------

[](#installation)

Package is available on [Packagist](https://packagist.org/packages/devraeph/laravel-xtoken), you can install it using [Composer](https://getcomposer.org).

```
composer require devraeph/laravel-xtoken
```

Migrate Database for token table

```
php artisan migrate
```

Publish Config

```
php artisan vendor:publish --provider="DevRaeph\XToken\JWTTokenServiceProvider" --tag="config"
```

Documentation
-------------

[](#documentation)

Model-Trait `HasXToken`
Example:

```
namespace App\Models;
use DevRaeph\XToken\Traits\HasXToken;

class User extends Authenticatable
{
    use HasFactory, HasXToken;

    ...
}
```

Issuing a Token:

```
use DevRaeph\XToken\Facades\Tokenizer;
use Carbon\CarbonImmutable;

$myJWT = Tokenizer::setModel(/* MODEL eg USER */)
        ->setIssuedBy(/* Default is env("APP_URL") */)
        ->setExpiresAt(CarbonImmutable::now()->addDays(15))
        ->createToken();

return $myJWT->toArray(); //Return Token Array
return $myJWT->toJson();  //Return Token Json
```

Using Middelware in Routes to parse Token:

```
/*
 * Use exsisting `xToken` middleware
 */
Route::group(['middleware' => ['api','xToken']], function () {
    Route::post("verify",function (){
        echo "Checked Token -> Valid";
    });
});
```

Get TokenClaim -&gt; ID of Model

```
use App\Models\User;
use DevRaeph\XToken\Facades\TokenizerClaim;

$myClaim = TokenizerClaim::setRequest($request)
    ->get();

$myUser = User::whereId($myClaim)->first();
```

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 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 ~70 days

Recently: every ~140 days

Total

9

Last Release

1361d ago

Major Versions

0.5.3 → v1.0.02021-02-06

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/58560217?v=4)[Raphael Planer](/maintainers/devraeph)[@DevRaeph](https://github.com/DevRaeph)

---

Top Contributors

[![DevRaeph](https://avatars.githubusercontent.com/u/58560217?v=4)](https://github.com/DevRaeph "DevRaeph (18 commits)")

### Embed Badge

![Health badge](/badges/devraeph-laravel-xtoken/health.svg)

```
[![Health](https://phpackages.com/badges/devraeph-laravel-xtoken/health.svg)](https://phpackages.com/packages/devraeph-laravel-xtoken)
```

###  Alternatives

[tymon/jwt-auth

JSON Web Token Authentication for Laravel and Lumen

11.5k49.1M350](/packages/tymon-jwt-auth)[league/oauth2-server

A lightweight and powerful OAuth 2.0 authorization and resource server library with support for all the core specification grants. This library will allow you to secure your API with OAuth and allow your applications users to approve apps that want to access their data from your API.

6.6k136.0M248](/packages/league-oauth2-server)[php-open-source-saver/jwt-auth

JSON Web Token Authentication for Laravel and Lumen

8359.8M53](/packages/php-open-source-saver-jwt-auth)[kreait/firebase-tokens

A library to work with Firebase tokens

24040.8M14](/packages/kreait-firebase-tokens)[scheb/2fa

Two-factor authentication for Symfony applications (please use scheb/2fa-bundle to install)

578630.7k1](/packages/scheb-2fa)[steverhoades/oauth2-openid-connect-server

An OpenID Connect Server that sites on The PHP League's OAuth2 Server

2097.8M12](/packages/steverhoades-oauth2-openid-connect-server)

PHPackages © 2026

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