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

ActiveLibrary[Security](/categories/security)

cruxoid/slim2-csrf
==================

Slim2 Security Library for CSRF

v1.2(5y ago)114GPLPHPPHP &gt;=7.0

Since Oct 23Pushed 5y ago1 watchersCompare

[ Source](https://github.com/cruxoid/slim2-csrf)[ Packagist](https://packagist.org/packages/cruxoid/slim2-csrf)[ Docs](https://cruxoid.com)[ RSS](/packages/cruxoid-slim2-csrf/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (2)DependenciesVersions (3)Used By (0)

slim2-csrf
==========

[](#slim2-csrf)

Simple Implementation of CSRF in Slim2 Framework

Getting Started
===============

[](#getting-started)

Download via composer with this command

composer require cruxoid/slim2-csrf

Setting Up Reference
====================

[](#setting-up-reference)

You might be having slim initiated like the following

```
$app = new \Slim\Slim(array(
        'templates.path' => './app/templates',
        'view' => new \Slim\Views\Twig(),
        'cookies.encrypt' => true,

       )
);

```

Add the following line

```
$app->add( new  Cruxoid\Middleware\CsrfMiddleware);

```

You are all set, now head back to your twig template and add the following inside forms

```

  Favorite color:
  Submit

```

Validating CSRF Token
=====================

[](#validating-csrf-token)

Validate post form data that contains CSRF Token aginst session data i.e.

```
 $csrf_token = $_POST['csrf_token'];
 $session_csrf_token = $_SESSION['csrf_token'];

if($csrf_token == $session_csrf_token){
//successfully token match, proceed with the form submission
} else {
//CSRF Voilated, error!!
}

```

You are all set!

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 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 ~0 days

Total

2

Last Release

2028d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/24b02352babd2e61923a9e621ff2023c796d4ff92eda19e9d2b02d95fd252cd8?d=identicon)[acruxoid](/maintainers/acruxoid)

---

Top Contributors

[![acruxoid](https://avatars.githubusercontent.com/u/73298506?v=4)](https://github.com/acruxoid "acruxoid (3 commits)")

### Embed Badge

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

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

###  Alternatives

[defuse/php-encryption

Secure PHP Encryption Library

3.9k162.4M214](/packages/defuse-php-encryption)[roave/security-advisories

Prevents installation of composer packages with known security vulnerabilities: no API, simply require it

2.9k97.3M6.4k](/packages/roave-security-advisories)[mews/purifier

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

2.0k16.7M113](/packages/mews-purifier)[robrichards/xmlseclibs

A PHP library for XML Security

41278.1M118](/packages/robrichards-xmlseclibs)[bjeavons/zxcvbn-php

Realistic password strength estimation PHP library based on Zxcvbn JS

86917.5M63](/packages/bjeavons-zxcvbn-php)[enlightn/security-checker

A PHP dependency vulnerabilities scanner based on the Security Advisories Database.

33732.2M110](/packages/enlightn-security-checker)

PHPackages © 2026

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