PHP code example of fyre / csrf

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

    

fyre / csrf example snippets


use Fyre\Security\CsrfProtection;

$csrfProtection = new CsrfProtection($container, $config);

$container->use(Config::class)->set('Csrf', $options);

$container->singleton(CsrfProtection::class);

$csrfProtection = $container->use(CsrfProtection::class);

$response = $csrfProtection->beforeResponse($request, $response);

$csrfProtection->checkToken($request);

$cookieToken = $csrfProtection->getCookieToken();

$field = $csrfProtection->getField();

$formToken = $csrfProtection->getFormToken();

$header = $csrfProtection->getHeader();

use Fyre\Security\Middleware\CsrfProtectionMiddleware;

$middleware = new CsrfProtectionMiddleware($csrfProtection);

$middleware = $container->build(CsrfProtectionMiddleware::class);

$response = $middleware->handle($request, $next);