PHP code example of rdcstarr / laravel-easyapi

1. Go to this page and download the library: Download rdcstarr/laravel-easyapi 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/ */

    

rdcstarr / laravel-easyapi example snippets


use Rdcstarr\EasyApi\Facades\EasyApi;

// Generate a new API key (returns the Api model)
$api = EasyApi::createKey();
$fullKey = $api->key; // show and store this securely

// Validate a key (returns bool)
$isValid = EasyApi::validateKey($fullKey);

// Delete a key
EasyApi::deleteKey($fullKey);

Route::middleware([\Rdcstarr\EasyApi\Middleware\EasyApiMiddleware::class])->group(function () {
    Route::get('/protected', function () {
        return ['ok' => true];
    });
});
bash
php artisan easyapi:install
bash
php artisan vendor:publish --tag=easyapi-migrations
bash
php artisan migrate
bash
php artisan easyapi generate
php artisan easyapi list
php artisan easyapi delete --key="qwerty_..."
php artisan easyapi reveal --id=1