1. Go to this page and download the library: Download clystnet/laravel-jwt library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
php
namespace App\Http\Controllers;
class ContentController extends Controller
{
public function __construct()
{
$this->middleware('laravel.jwt');
}
}
php
// This will attempt to authenticate the user using the credentials passed and returns a JWT Auth Token for subsequent requests.
$token = Auth::attempt(['email' => '[email protected]', 'password' => '123456']);
php
if(Auth::onceUsingId(1)) {
// Do something with the authenticated user
}
php
if(Auth::once(['email' => '[email protected]', 'password' => '123456'])) {
// Do something with the authenticated user
}