Download the PHP package unisharp/laravel-jwt without Composer

On this page you can find all versions of the php package unisharp/laravel-jwt. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-jwt

Laravel JWT

php-badge Latest Version on Packagist Build Status Coverage Status Quality Score Total Downloads

Approach

If you pick Tymon JWTAuth as your jwt solution in your project, when you try to refresh your token, the package will blacklist your exchanged token (assume your blacklist feature is enabled). So when your client faces a concurrency use case, your request might be rejected because that request is sent before your app renews jwt token returned by server. This package caches the refreshed jwt token in a short period to ensure your client side can get correct response even if your request carries an old token in a concurrency case.

Important Change

We change our namespace Unisharp\JWT to UniSharp\JWT

Installation

In Lumen please use Tymon\JWTAuth\Providers\LumenServiceProvider::class,

Next, also in the app.php config file, under the aliases array, you may want to add the JWTAuth facade.

Finally, you will want to publish the config using the following command:

Don't forget to set a secret key in the config file!

this will generate a new random key, which will be used to sign your tokens.

And you're done!

Usage

Open your config/auth.php config file and in place of driver under any of your guards, just add the jwt-auth as your driver and you're all set. Make sure you also set provider for the guard to communicate with your database.

Setup Guard Driver

Middleware Usage

Middleware protecting the route:

Middleware protecting the controller:

This middleware will automatically refresh jwt token if the existing one has been expired. The new refreshed jwt token will be carried to the response header: Ahthorization. The client side needs to replace your expired jwt token with the new one.

Note: The above example assumes you've setup a guard with the name api whose driver is jwt-auth in your config/auth.php file as explained in "Setup Guard Driver" section above.

The following usage examples assume you've setup your default auth guard to the one which uses the jwt-auth driver.

You can also explicitly define the guard before making calls to any of methods by just prefixing it with Auth::guard('api').

Example: Auth::guard('api')->user()

Attempt To Authenticate And Return Token

Authenticate Once By ID

Authenticate Once By Credentials

Validate Credentials

Check User is Authenticated

Check User is a Guest

Logout Authenticated User

Generate JWT Auth Token By ID

Get Authenticated User

Once the user is authenticated via a middleware, You can access its details by doing:

You can also manually access user info using the token itself:

Get Authenticated User's ID

Refresh Expired Token

Though it's recommended you refresh using the middlewares provided with the package, but if you'd like, You can also do it manually with this method.

Refresh expired token passed in request:

Refresh passed expired token:

Invalidate Token

Invalidate token passed in request:

Invalidate token by setting one manually:

Get Token

Get Token Payload

This method will decode the token and return its raw payload.

Get Payload for the token passed in request:

Get Payload for the given token manually:


All versions of laravel-jwt with dependencies

PHP Build Version
Package Version
Requires php Version ^5.6.4 || ^7.0
tymon/jwt-auth Version 1.0.0-rc.2
illuminate/support Version >=5.0.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package unisharp/laravel-jwt contains the following files

Loading the files please wait ....