1. Go to this page and download the library: Download matbcvo/laravel-token-auth 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/ */
matbcvo / laravel-token-auth example snippets
use Illuminate\Support\Facades\Route;
Route::middleware('auth.token')->group(function () {
Route::get('/protected-route', function () {
return response()->json(['message' => 'You have access to this route!']);
});
});
use Illuminate\Support\Facades\Route;
use Matbcvo\LaravelTokenAuth\Http\Middleware\AuthenticateApiToken;
Route::middleware(AuthenticateApiToken::class)->group(function() {
Route::get('/protected-route', function () {
return response()->json(['message' => 'You have access to this route!']);
});
});