PHPackages                             athens/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. athens/csrf

ActiveLibrary[Security](/categories/security)

athens/csrf
===========

Simple CSRF protection

2.1.0(9y ago)17.3k↓87.5%1[2 issues](https://github.com/AthensFramework/csrf/issues)[1 PRs](https://github.com/AthensFramework/csrf/pulls)2PHP

Since Aug 21Pushed 9y ago1 watchersCompare

[ Source](https://github.com/AthensFramework/csrf)[ Packagist](https://packagist.org/packages/athens/csrf)[ RSS](/packages/athens-csrf/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (3)Dependencies (4)Versions (10)Used By (2)

[![Build Status](https://camo.githubusercontent.com/dbc0150fafc24bb8e7c94ff41832d42428f702b20ca5df4a1a9164e991607135/68747470733a2f2f7472617669732d63692e6f72672f417468656e734672616d65776f726b2f637372662e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/AthensFramework/csrf)[![Code Climate](https://camo.githubusercontent.com/a3a35da2dc5e60840f1c68c5704cb59c9b5785b2a25acab49a408f127e0e8e56/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f417468656e734672616d65776f726b2f637372662f6261646765732f6770612e737667)](https://codeclimate.com/github/AthensFramework/csrf)[![Test Coverage](https://camo.githubusercontent.com/41928d47be15d214490a9fbb757539679c927fc96a80b4ce319e13bfffe215d1/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f417468656e734672616d65776f726b2f637372662f6261646765732f636f7665726167652e737667)](https://codeclimate.com/github/AthensFramework/csrf/coverage)[![Latest Stable Version](https://camo.githubusercontent.com/46a862bb292ab262466af09088a85669183ebdc847c9ad270dd0635f21f7c69c/68747470733a2f2f706f7365722e707567782e6f72672f617468656e732f637372662f762f737461626c65)](https://packagist.org/packages/athens/csrf)

Athens/CSRF
===========

[](#athenscsrf)

Easily protect against [CSRF](https://www.owasp.org/index.php/Cross-Site_Request_Forgery_(CSRF)) attacks.

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

[](#installation)

This library is published on packagist. To install using Composer, add the `"athens/csrf": "0.1.*"` line to your "require" dependencies:

```
{
    "require": {
        ...
        "athens/csrf": "1.*",
        ...
    }
}

```

Of course, if you're not using Composer then you can download the repository using the *Download ZIP* button at right.

Use
---

[](#use)

Using this package requires only two lines:

```
    // Import the CSRF class
    use Athens\CSRF\CSRF;

    // Intialize
    CSRF::init();

```

The method `::init()` will automatically insert a hidden CSRF token field into your forms:

```

    ...

    ...

```

This token will be included automatically in any of your form submissions.

Incase you perform form submission via AJAX, `::init()` also inserts a `CSRF_TOKEN` variable into your javascript:

```

    ...

        var CSRFTOKEN = '37328bc2cac3e73623bc38ab0f4068ee7fa1';
    ...

```

This token will not automatically be included in your AJAX requests, but you may include it manually by referring to the `CSRFTOKEN` var in your submission script.

Compatibility
-------------

[](#compatibility)

- PHP 5.5, 5.6, 7.0

Todo
----

[](#todo)

See GitHub [issue tracker](https://github.com/AthensFramework/CSRF/issues/).

Getting Involved
----------------

[](#getting-involved)

Feel free to open pull requests or issues. [GitHub](https://github.com/AthensFramework/CSRF) is the canonical location of this project.

Here's the general sequence of events for code contribution:

1. Open an issue in the [issue tracker](https://github.com/AthensFramework/CSRF/issues/).
2. In any order:

- Submit a pull request with a **failing** test that demonstrates the issue/feature.
- Get acknowledgement/concurrence.

3. Revise your pull request to pass the test in (2). Include documentation, if appropriate.

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~55 days

Recently: every ~73 days

Total

9

Last Release

3520d ago

Major Versions

0.1.1 → 1.0.02015-12-17

1.2.0 → 2.0.02016-02-23

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/6137968?v=4)[JASchilz](/maintainers/JASchilz)[@JASchilz](https://github.com/JASchilz)

![](https://www.gravatar.com/avatar/290ab676b0d7a71324f5e5b1cd29b339cd379449c10bb721fd3f7d7d6b7571f1?d=identicon)[BonPacific](/maintainers/BonPacific)

![](https://www.gravatar.com/avatar/df9465816cfe9d8b479d9b7de09a7a3b8b8e493d4316b3143179bfaf4b8d53c4?d=identicon)[wizzah](/maintainers/wizzah)

---

Top Contributors

[![JASchilz](https://avatars.githubusercontent.com/u/6137968?v=4)](https://github.com/JASchilz "JASchilz (42 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/athens-csrf/health.svg)

```
[![Health](https://phpackages.com/badges/athens-csrf/health.svg)](https://phpackages.com/packages/athens-csrf)
```

###  Alternatives

[mews/purifier

Laravel 5/6/7/8/9/10 HtmlPurifier Package

2.0k18.0M134](/packages/mews-purifier)[paragonie/ecc

PHP Elliptic Curve Cryptography library

24772.0k35](/packages/paragonie-ecc)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
