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

AbandonedArchivedLibrary[Security](/categories/security)

sciencehook/csrf-xsrf
=====================

CSRF attack protection library

1.0.0(7y ago)115MITPHPPHP ^7

Since Nov 25Pushed 7y ago1 watchersCompare

[ Source](https://github.com/kkumar326/CSRF-XSRF)[ Packagist](https://packagist.org/packages/sciencehook/csrf-xsrf)[ RSS](/packages/sciencehook-csrf-xsrf/feed)WikiDiscussions master Synced 4d ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

 [![](https://camo.githubusercontent.com/d7ff3da977530e0fc5f0bce44de96d65abf5c07df945ac23570d73db8e4acd97/68747470733a2f2f7062732e7477696d672e636f6d2f70726f66696c655f696d616765732f313038313631303134313533383131313438382f6a413434514c4f695f343030783430302e6a7067)](https://camo.githubusercontent.com/d7ff3da977530e0fc5f0bce44de96d65abf5c07df945ac23570d73db8e4acd97/68747470733a2f2f7062732e7477696d672e636f6d2f70726f66696c655f696d616765732f313038313631303134313533383131313438382f6a413434514c4f695f343030783430302e6a7067)

---

**CSRF/ XSRF Security mini library for PHP applications. Embed and verify security tokens in forms without much hassle.**

---

[![Generic badge](https://camo.githubusercontent.com/b120b29e43e5081edbe97607a4123e57b8e6deff5d17c2d0cc417aa70b7e6fa5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f617574686f722d4b73686974696a2532304b756d61722d7265642e737667)](https://twitter.com/kkumar326)[![Generic badge](https://camo.githubusercontent.com/c6f8b7c041cfe196f2edd45f1b9a4c9ea9636c128efc363cfe1df9e286c1a64e/68747470733a2f2f7472617669732d63692e6f72672f6b6b756d61723332362f435352462d585352462e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/kkumar326/CSRF-XSRF)[![Latest Stable Version](https://camo.githubusercontent.com/001846c9556106b7b09c59f82508cf4726fb579331bc670499e8fedf67e8de7d/68747470733a2f2f706f7365722e707567782e6f72672f736369656e6365686f6f6b2f637372662d787372662f762f737461626c65)](https://packagist.org/packages/sciencehook/csrf-xsrf)[![Test Coverage](https://camo.githubusercontent.com/2ffa875b873fab41dd541dfaf5d0dbd828b573d29d696e24e226a77e6483b916/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f36636566636365326161386236623236616330612f746573745f636f766572616765)](https://codeclimate.com/github/kkumar326/CSRF-XSRF/test_coverage)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/db0499ce53072bab8cca7b56d3dfe8310d801262852e4eaa9d8ed9befccaebd2/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6b6b756d61723332362f435352462d585352462f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/kkumar326/CSRF-XSRF/?branch=master)[![Total Downloads](https://camo.githubusercontent.com/ae7b9a3f3f303ba58c2e717e7a92a09a02cbe1ac078369ea40d8a642b77030a4/68747470733a2f2f706f7365722e707567782e6f72672f736369656e6365686f6f6b2f637372662d787372662f646f776e6c6f616473)](https://packagist.org/packages/sciencehook/csrf-xsrf)[![License](https://camo.githubusercontent.com/bc8c5ddb8697e948e6c6f2f4af5e8cb9bf2b63e5fb15b5e6b456637db602f250/68747470733a2f2f706f7365722e707567782e6f72672f736369656e6365686f6f6b2f637372662d787372662f6c6963656e7365)](https://packagist.org/packages/sciencehook/csrf-xsrf)

---

Table of Contents
-----------------

[](#table-of-contents)

1. [Installation](#installation)
2. [Usage Examples](#examples)
3. [Contribution](#contribution)
4. [License](#license)

---

### Installation

[](#installation)

#### Requirements:

[](#requirements)

**PHP**

This library is developed and tested on PHP 7.2. We do not know its backward compatibility. So, please test it before using it for PHP version less than 7.2.

#### Steps:

[](#steps)

First, get [Composer](https://getcomposer.org/download/), if you don't already have it.

Next, run the following command in your terminal in PROJECT's directory:

`composer require sciencehook/csrf-xsrf`---

### Usage Examples

[](#usage-examples)

You can find the working examples in [examples](https://github.com/kkumar326/CSRF-XSRF/tree/master/examples) folder.

[input\_form.php](https://github.com/kkumar326/CSRF-XSRF/blob/master/examples/input_form.php) is input form containing CSRF token and [form\_validation.php](https://github.com/kkumar326/CSRF-XSRF/blob/master/examples/form_validation.php) validates the token and proceeds accordingly.

---

### Contribution

[](#contribution)

Please raise issues in case of any bugs or problems. To contribute, please create pull requests.

---

### License

[](#license)

**MIT License**

Copyright (c) 2018 [ScienceHook](https://sciencehook.com/)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity61

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

Unknown

Total

1

Last Release

2728d ago

### Community

Maintainers

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

---

Top Contributors

[![kkumar326](https://avatars.githubusercontent.com/u/5160841?v=4)](https://github.com/kkumar326 "kkumar326 (6 commits)")

---

Tags

securitycsrfxsrf

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[paragonie/anti-csrf

Paragon Initiative's Anti-CSRF Security Library

307200.6k5](/packages/paragonie-anti-csrf)[owasp/csrf-protector-php

CSRF protector php, a standalone php library for csrf mitigation in web applications. Easy to integrate in any php web app.

222348.3k4](/packages/owasp-csrf-protector-php)[dneustadt/csrf-cookie-bundle

CSRF protection cookie for use with XHR

1379.2k1](/packages/dneustadt-csrf-cookie-bundle)[riimu/kit-csrf

Secure and simple CSRF library protected against timing and BREACH attacks

6526.1k](/packages/riimu-kit-csrf)[ayesh/stateless-csrf

Secret-key based state-less CSRF token generator and validator for PHP 8. State-less means you do not have to store the CSRF token in session or database.

3223.3k](/packages/ayesh-stateless-csrf)[laragear/poke

Keep your forms alive, avoid TokenMismatchException by gently poking your Laravel app

2211.5k](/packages/laragear-poke)

PHPackages © 2026

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