Download the PHP package a2workspace/laravel-jwt without Composer

On this page you can find all versions of the php package a2workspace/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

一個幾乎零配置,隨開即用的 API 認證服務。


此套件是基於 php-open-source-saver/jwt-auth 的包裝,並提供一個簡易的 AuthenticatesUsers 特性方便擴充。

特性:

安裝

執行下列命令透過 composer 引入到你的 Laravel 專案:

接著,執行 laravel-jwt:install Artisan 指令來進行安裝。 該指令會生成設定檔,並注入 JWT_SECRET.env 中。

現在應該會有個 config/jwt.php 檔案。


快速開始

要讓你的 API 可以透過 jwt 登入需要做以下的設定:

修改 User 資料模型

首先讓你的 User 模型實作 A2Workspace\LaravelJwt\Contracts\JWTSubject 介面; 並將 A2Workspace\LaravelJwt\HasApiTokens 特性加到你的 User 模型中;

Interface A2Workspace\LaravelJwt\Contracts\JWTSubject 繼承自 PHPOpenSourceSaver\JWTAuth\Contracts\JWTSubject 設定可參考 Update your User model - Laravel JWT Auth

設定登入認證守衛 (Auth Guard)

接著,找到你專案的 config/auth.php 設定檔。將 apidriver 修改為 jwt

註冊路由

最後,你應該在 App\Providers\AuthServiceProviderboot 中註冊 LaravelJwt::routes:

自訂使用者回傳值

你可以透過覆寫 /api/auth/user 路徑來修改回傳的使用者資訊:


客製化認證控制器

這裡告訴你如何編寫自己的認證控制器,你可以參考 A2Workspace/laravel-social-entry-demo 中如何配置多使用者模型認證。

一個簡易範例:

引入認證特性到控制器中

A2Workspace\LaravelJwt\AuthenticatesUsers 提供了 JWT 登入認證所需的所有方法,僅需要在控制器中使用該特性,並註冊到專案的路由檔案。

指定認證守衛

需對應 configs/auth.php 中的 guards 名稱,且 driver 必須為 jwt

指定登入時的帳號欄位

預設為 username,你可以自行修改為 phoneemailaccount...等。

註冊路由

注意: 當使用自訂控制器時,就不需要在 App\Providers\AuthServiceProvider 中重複註冊 LaravelJwt:routes 了。


Nuxt Support

此套件相容於 Nuxtauth-nuxt 模組中的 Laravel JWT (參考這裡)。

當使用 UserResource 時,由於使用者資料是放在 data 欄位而不是最頂層,需增加 user.property 的設定:


All versions of laravel-jwt with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4|^8.0
php-open-source-saver/jwt-auth Version ^1.4
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 a2workspace/laravel-jwt contains the following files

Loading the files please wait ....