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 yesterday

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 51% 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

1455d 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

[php-open-source-saver/jwt-auth

JSON Web Token Authentication for Laravel and Lumen

84511.6M67](/packages/php-open-source-saver-jwt-auth)[scheb/2fa

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

589701.7k2](/packages/scheb-2fa)[scheb/2fa-trusted-device

Extends scheb/2fa-bundle with trusted devices support

366.0M40](/packages/scheb-2fa-trusted-device)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.8M672](/packages/shopware-core)[jeremy379/laravel-openid-connect

OpenID Connect support to the PHP League's OAuth2 Server. Compatible with Laravel Passport.

62473.7k10](/packages/jeremy379-laravel-openid-connect)[drenso/symfony-oidc-bundle

OpenID connect bundle for Symfony

97795.4k4](/packages/drenso-symfony-oidc-bundle)

PHPackages © 2026

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