PHP code example of circli / api-auth-extension

1. Go to this page and download the library: Download circli/api-auth-extension 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/ */

    

circli / api-auth-extension example snippets


use Circli\ApiAuth\Repository\ArrayBasicAuthRepository;
use Circli\ApiAuth\Provider\BasicAuthProvider;
use Circli\ApiAuth\Middleware\ApiAuthenticationMiddleware;

$authRepository = new ArrayBasicAuthRepository(['admin' => 'password']);

$middleware = new ApiAuthenticationMiddleware(new BasicAuthProvider($authRepository));

use Circli\ApiAuth\Repository\AccessKeyRepository;
use Circli\ApiAuth\Provider\AccessKeyProvider;
use Circli\ApiAuth\Middleware\ApiAuthenticationMiddleware;

$repository = new YourImplementationOfAccessKeyRepository();

$middleware = new ApiAuthenticationMiddleware(new AccessKeyProvider($repository));

use Circli\ApiAuth\Repository\AuthTokenRepository;
use Circli\ApiAuth\Provider\AuthTokenProvider;
use Circli\ApiAuth\Middleware\ApiAuthenticationMiddleware;

$repository = new YourImplementationOfAuthTokenRepository();

$middleware = new ApiAuthenticationMiddleware(new AuthTokenProvider($repository));