PHPackages                             pierresilva/laravel-jwt-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. pierresilva/laravel-jwt-auth

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

pierresilva/laravel-jwt-auth
============================

Laravel JWT auth api

0103PHP

Since Sep 7Pushed 5y ago1 watchersCompare

[ Source](https://github.com/pierresilva/laravel-jwt-auth)[ Packagist](https://packagist.org/packages/pierresilva/laravel-jwt-auth)[ RSS](/packages/pierresilva-laravel-jwt-auth/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel JWTAuth
===============

[](#laravel-jwtauth)

Laravel JWTAuth is a package to simplify [tymon/jwt-auth](https://github.com/tymondesigns/jwt-auth) installation in a new laravel project.

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

[](#installation)

Let’s install the package via Composer:

`composer require pierresilva/laravel-jwt-auth`

After that, add the service provider to the Providers array in your `config/app.php` file:

```
'providers' => [
     ...
    /*
     * Package Service Providers...
     */

    'Tymon\JWTAuth\Providers\LaravelServiceProvider',

    /*
     * Application Service Providers...
     */
     ...

],

```

Next, also in the `config/app.php` file, add the JWTAuth and JWTFactory facades to the aliases array.

```
'aliases' => [
    ...
    'JWTAuth' => 'Tymon\JWTAuth\Facades\JWTAuth',
    'JWTFactory' => 'Tymon\JWTAuth\Facades\JWTFactory'
],

```

After that, we publish the package’s config using the following command:

```
php artisan vendor:publish --provider="Tymon\JWTAuth\Providers\LaravelServiceProvider"

```

Finally, let’s generate a secret key that this package will use to encrypt our tokens:

```
php artisan jwt:secret

```

The above command generates an encryption key and sets it in the `.env` file with something like `JWT_SECRET=keystring`.

We will be using the existing User model for authentication, therefore, we need to integrate our user model with the jwt-auth package. To do that, we’ll implement the `Tymon\JWTAuth\Contracts\JWTSubject` contract on the user model and define the two required methods, `getJWTIdentifier()` and `getJWTCustomClaims()`.

In `app/User.php` file modify like this:

```
