1. Go to this page and download the library: Download phputil/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/ */
phputil / csrf example snippets
use phputil\router\Router;
use function phputil\crsf\crsf; // Step 1: Declare the namespace usage for the function.
$app = new Router();
$app->use( crsf() ); // Step 2: Invoke the function to use it as a middleware.
$app->get( '/', function( $req, $res ) {
$res->send( 'Hello' );
} );
$app->listen();
/**
* Returns a CSRF middleware.
*
* @param array|CsrfOptions $options CSRF options.
* @param CsrfStrategy $strategy Strategy. By default it uses a cookie-based strategy with default options.
* @param CsrfStorage $storage Storage. By default it uses a session-based storage with default options.
*
* @return callable
*/
function csrf( $options = [], CsrfStrategy $strategy = null, CsrfStorage $storage = null ): callable;
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.