PHP code example of archerzdip / laravel-api-auth
1. Go to this page and download the library: Download archerzdip/laravel-api-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/ */
archerzdip / laravel-api-auth example snippets
Route::get('api/user/1', function () {
//
})->middleware('auth.apikey');
class UserController extends Controller
{
/**
* Instantiate a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth.apikey');
}
}
sign = sha1(appid . secret . exp) // exp = time()
token = base64_encode(implode('.', [appid, sign, exp])