basteyy/plates-slim-csrf

A Plates Extension for using the Slim CSRF Middleware

0.0.1 2021-04-21 18:47 UTC

This package is auto-updated.

Last update: 2024-11-15 18:53:39 UTC


README

An extension for plates to use the csrf function from the slim framework

Install

Use composer to install the script:

composer require basteyy/plates-slim-csrf

Usage

<?php

// Add Csrf to your app according to the documentation here: https://github.com/slimphp/Slim-Csrf
$container->set('csrf', function () use ($responseFactory) {
    return new \Slim\Csrf\Guard($responseFactory);
});

// Add the plates like the documentation here: https://platesphp.com/engine/extensions/
$templates = new League\Plates\Engine('/path/to/templates');

// Add the extension to plates and forwad the csrf GuardClass:
$templates->loadExtension(new \basteyy\PlatesSlimCsrf\PlatesSlimCsrf($container->get('csrf')));

// Inside your form use echo the following:
echo $this->getCsrf(); 

License

The MIT License (MIT). Please see License File for more information.