PHPackages                             babicaja/jwt-4laravel - 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. babicaja/jwt-4laravel

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

babicaja/jwt-4laravel
=====================

This is a Laravel package which provides all the means for a super easy JWT implementation

v1.2.2(6y ago)3024[2 PRs](https://github.com/babicaja/jwt-4laravel/pulls)MITPHPPHP ^7.3

Since May 17Pushed 4y ago2 watchersCompare

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

READMEChangelogDependencies (4)Versions (10)Used By (0)

JWT for Laravel
===============

[](#jwt-for-laravel)

> This is a Laravel package which provides all the means for a super easy JWT implementation

[![Latest Version on Packagist](https://camo.githubusercontent.com/4e24773750128c6ca58f5a57aa784fb2b462a75c2fac4585ef7b48426a5092f8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6261626963616a612f6a77742d346c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/babicaja/jwt-4laravel)[![Total Downloads](https://camo.githubusercontent.com/978dcd2b23ce79bade3909005dbe5bdeb24c2904b8377468ac724e2c6935e1fb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6261626963616a612f6a77742d346c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/babicaja/jwt-4laravel)[![Build Status](https://camo.githubusercontent.com/ebebb9e5336a705f339938f40bf76edfb1200eeeca6b9b09e87eabb31a8e26a7/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6261626963616a612f6a77742d346c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/babicaja/jwt-4laravel.svg)[![Coverage](https://camo.githubusercontent.com/8dc78b765f718056a37cb0eac09a9b3b0e98280e93dc08c0d6ba574c0d05a086/68747470733a2f2f636f6465636f762e696f2f67682f6261626963616a612f6a77742d346c61726176656c2f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/babicaja/jwt-4laravel)[![Licence](https://camo.githubusercontent.com/41ba377241cdf9790f93843f65483838dbfa3d4a79db51fce30030c665f813e6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6261626963616a612f6a77742d346c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://github.com/babicaja/jwt-4laravel)

- [Installation](#installation)
- [Getting started](#getting-started)
- [Configuration](#configuration)
- [Usage](#usage)
- [Checks](#checks)
- [Contributing](#contributing)

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

[](#installation)

Make sure you include this package as part of your Laravel project. You can do so by running the composer command from below.

```
composer require babicaja/jwt-4laravel
```

Getting started
---------------

[](#getting-started)

First register the service provider with the `artisan vendor:publish` command. This will ensure all the bindings are in place and it will copy the default configuration file to your app's config folder.

```
php artisan vendor:publish // Choose JWT4L\Providers\JWTServiceProvider from the list
```

Inspect the newly created `config/jwt.php` file. For now, you can leave it as it is (don't forget to change the `secret` key for production). Details about the configuration are covered in this [section](#configuration).

Now everything is in place and you can start using the JWT for Laravel's functionality. Easiest way to see it in actions is using the `Token` Facade provided by the package, and through `artisan tinker`. If you are able to see a similar output as the one below, you are all set.

```
php artisan tinker
Psy Shell v0.9.9 (PHP 7.3.6-1+ubuntu18.04.1+deb.sury.org+1 — cli) by Justin Hileman
>>> Token::create()
=> "eyJ0eXAiOiJKV1QiLCJhbGciOiJzaGEyNTYifQ==.eyJpYXQiOiIyMDE5LTA3LTAyVDE1OjAyOjQ5LjkzMTQwMloiLCJleHAiOiIyMDE5LTA3LTAyVDE1OjE3OjQ5LjkzMTQ2M1oifQ==.fa0f19c3a2a444d72bb58feb54227677e52c65e35f3db21b31673520ddb16c86"
```

Configuration
-------------

[](#configuration)

Out of the box the configuration file comes with default values which you can use as they are. You should probably change the `secret` for any production code. You can set the values directly in the `config/jwt.php` file or preferably by setting the appropriate `.env` values.

> config/jwt.php

```
