PHPackages                             enlivenapp/flight-csrf - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Security](/categories/security)
4. /
5. enlivenapp/flight-csrf

ActiveFlightphp-plugin[Security](/categories/security)

enlivenapp/flight-csrf
======================

CSRF protection middleware and helpers for FlightPHP

0.2.1(2mo ago)0143MITPHPPHP ^8.1

Since Apr 18Pushed 2mo agoCompare

[ Source](https://github.com/enlivenapp/FlightPHP-CSRF)[ Packagist](https://packagist.org/packages/enlivenapp/flight-csrf)[ RSS](/packages/enlivenapp-flight-csrf/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (1)Dependencies (1)Versions (5)Used By (3)

[![Stable? Not Quite Yet](https://camo.githubusercontent.com/8712c441bb32fd8db507e0008c5d13e30def50064f8fcbc689fbcf5191f7d2af/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f737461626c652533462d6e6f7425323071756974652532307965742d626c75653f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/enlivenapp/flight-csrf)[![License](https://camo.githubusercontent.com/8d47be7412f082a429796057450ba17af7028816d2df7744ef95d4d3efeb4f76/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f656e6c6976656e6170702f666c696768742d637372663f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/enlivenapp/flight-csrf)[![PHP Version](https://camo.githubusercontent.com/56f742b7cfdf3d218bd61a7fb76109d25bc4527d89ece8b2481bd61a83ac8088/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f656e6c6976656e6170702f666c696768742d637372663f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/enlivenapp/flight-csrf)[![Monthly Downloads](https://camo.githubusercontent.com/04913cd2dc0f5e4e99ccbab6564deef5532028535910608866a2d070e4932c76/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f656e6c6976656e6170702f666c696768742d637372663f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/enlivenapp/flight-csrf)[![Total Downloads](https://camo.githubusercontent.com/83364f2e3d7163ab866e5a725ba6ae506c02c9d8a4bfa153b990abd81234433f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f656e6c6976656e6170702f666c696768742d637372663f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/enlivenapp/flight-csrf)[![GitHub Issues](https://camo.githubusercontent.com/a157ca7ce9ee33fa7550df319e65efc6334fab7ca17d3281057db02e631ab040/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f656e6c6976656e6170702f466c696768745048502d435352463f7374796c653d666f722d7468652d6261646765)](https://github.com/enlivenapp/FlightPHP-CSRF/issues)[![Contributors](https://camo.githubusercontent.com/3e2db9ce8660ae66594251c4a32a66accfdd5806505e44612944812012a5195f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f636f6e7472696275746f72732f656e6c6976656e6170702f466c696768745048502d435352463f7374796c653d666f722d7468652d6261646765)](https://github.com/enlivenapp/FlightPHP-CSRF/graphs/contributors)[![Latest Release](https://camo.githubusercontent.com/01b0aabd3f270dd326b891419b71c54a3de3f6849ef062ed7c554436f093aca4/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f656e6c6976656e6170702f466c696768745048502d435352463f7374796c653d666f722d7468652d6261646765)](https://github.com/enlivenapp/FlightPHP-CSRF/releases)[![Contributions Welcome](https://camo.githubusercontent.com/9db3f8b82ea88469efd296a9305fc00f40b4c9450bb6b539d42d339fa6963444/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f6e747269627574696f6e732d77656c636f6d652d626c75653f7374796c653d666f722d7468652d6261646765)](https://github.com/enlivenapp/FlightPHP-CSRF/pulls)

flight-csrf
===========

[](#flight-csrf)

**I noticed folks downloading some of these packages. I'm super grateful, Thank You! I would like to let folks know until this notice disappears I'm doing a lot of breaking changes without worrying about them. Once versions are up around 0.5.x things should settle down.**

CSRF protection middleware and helpers for [FlightPHP](https://flightphp.com), built for the [flight-school](https://github.com/enlivenapp/flight-school) plugin system.

Requirements
------------

[](#requirements)

- PHP 8.1+
- `enlivenapp/flight-school` ^0.2

Installation
------------

[](#installation)

```
composer require enlivenapp/flight-csrf
```

Flight School auto-discovers the package via its `flightphp-plugin` composer type. Enable it in your app config:

```
// app/config/config.php
return [
    // ...
    'plugins' => [
        'enlivenapp/flight-csrf' => [
            'enabled' => true,
        ],
    ],
];
```

Usage
-----

[](#usage)

### Forms

[](#forms)

Use `csrf_field()` to output a hidden input in any HTML form. The token is generated and stored in the session automatically.

```

    Log in

```

### AJAX requests

[](#ajax-requests)

Use `csrf_token()` to retrieve the raw token value. The most common pattern is to embed it in a meta tag and read it from JavaScript.

```
