PHP code example of hadefication / simple-token-auth
1. Go to this page and download the library: Download hadefication/simple-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/ */
// Using the middleware class directly
Route::middleware(\Hadefication\SimpleTokenAuth\Http\Middleware\SimpleTokenAuthMiddleware::class)
->group(function () {
Route::get('/api/protected', function () {
return response()->json(['message' => 'Authenticated!']);
});
});
// Using the registered middleware alias
Route::middleware('simple-token-auth')
->group(function () {
Route::get('/api/protected', function () {
return response()->json(['message' => 'Authenticated!']);
});
});