PHP code example of altelma / laravel-hydra

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

    

altelma / laravel-hydra example snippets


// Example in middleware
public function __construct(private AdminApi $oauthAdminApi)
{
}

public function handle(Request $request, Closure $next)
{
    $token = $request->bearerToken();
    $tokenVerification = $this->oauthAdminApi->introspectOAuth2Token($token)->active;
    if (!$tokenVerification) {
        throw new UnauthorizedHttpException('Bearer', 'Invalid access token');
    }

    return $next($request);
}