PHPackages                             mezzio/mezzio-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. [HTTP &amp; Networking](/categories/http)
4. /
5. mezzio/mezzio-csrf

ActiveLibrary[HTTP &amp; Networking](/categories/http)

mezzio/mezzio-csrf
==================

CSRF token generation and validation for PSR-7 and PSR-15 applications using mezzio-session

1.11.0(8mo ago)8257.6k↓32.3%9[1 issues](https://github.com/mezzio/mezzio-csrf/issues)[1 PRs](https://github.com/mezzio/mezzio-csrf/pulls)4BSD-3-ClausePHPPHP ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0CI passing

Since Dec 31Pushed 1w ago11 watchersCompare

[ Source](https://github.com/mezzio/mezzio-csrf)[ Packagist](https://packagist.org/packages/mezzio/mezzio-csrf)[ Docs](https://mezzio.dev)[ Fund](https://funding.communitybridge.org/projects/laminas-project)[ RSS](/packages/mezzio-mezzio-csrf/feed)WikiDiscussions 1.12.x Synced 3d ago

READMEChangelog (10)Dependencies (7)Versions (33)Used By (4)

mezzio-csrf
===========

[](#mezzio-csrf)

[![Build Status](https://github.com/mezzio/mezzio-csrf/actions/workflows/continuous-integration.yml/badge.svg)](https://github.com/mezzio/mezzio-csrf/actions/workflows/continuous-integration.yml)

> ## 🇷🇺 Русским гражданам
>
> [](#-русским-гражданам)
>
> Мы, участники Laminas, родились и живем в разных странах. У многих из нас есть друзья, родственники и коллеги как в России, так и в Украине. Некоторые из нас родились в России. Некоторые из нас живут в России. У некоторых бабушки и дедушки сражались с фашистами во Второй мировой войне. Здесь никто не поддерживает фашизм.
>
> У одного из нас есть украинская родственница, которая спаслась из дома вместе с сыном. Поезд задержался из-за бомбежки на дороге впереди. У нас есть друзья, которые прячутся в бомбоубежищах. Мы с тревогой ждем весточки от них после воздушных налетов, которые беспорядочно наносят удары и попадают по больницам, школам, детским садам и домам. Мы не берем это из каких-либо СМИ. Мы наблюдаем это напрямую.
>
> Вы доверяете нам достаточно, чтоб использовать наши программы, и мы просим вас довериться нам вновь. Мы нуждаемся в помощи. Выходите и протестуйте против этой бесполезной войны. Остановите кровопролитие. Скажите "Нет войне!"
>
> ## 🇺🇸 To Citizens of Russia
>
> [](#-to-citizens-of-russia)
>
> We at Laminas come from all over the world. Many of us have friends, family and colleagues in both Russia and Ukraine. Some of us were born in Russia. Some of us currently live in Russia. Some have grandparents who fought Nazis in World War II. Nobody here supports fascism.
>
> One team member has a Ukrainian relative who fled her home with her son. The train was delayed due to bombing on the road ahead. We have friends who are hiding in bomb shelters. We anxiously follow up on them after the air raids, which indiscriminately fire at hospitals, schools, kindergartens and houses. We're not taking this from any media. These are our actual experiences.
>
> You trust us enough to use our software. We ask that you trust us to say the truth on this. We need your help. Go out and protest this unnecessary war. Stop the bloodshed. Say "stop the war!"

Provides CSRF token generation and validation for PSR-7 applications, using [mezzio-session](https://docs.mezzio.dev/mezzio-session), and optionally [mezzio-flash](https://docs.mezzio.dev/mezzio-flash).

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

[](#installation)

Run the following to install this library:

```
$ composer require mezzio/mezzio-csrf
```

Documentation
-------------

[](#documentation)

Documentation is [in the doc tree](docs/book/), and can be compiled using [mkdocs](https://www.mkdocs.org):

```
$ mkdocs build
```

You may also [browse the documentation online](https://docs.mezzio.dev/mezzio-csrf/).

###  Health Score

63

—

FairBetter than 99% of packages

Maintenance78

Regular maintenance activity

Popularity42

Moderate usage in the ecosystem

Community31

Small or concentrated contributor base

Maturity86

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 56.9% 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 ~79 days

Recently: every ~155 days

Total

31

Last Release

6d ago

Major Versions

0.1.0 → 1.0.02019-12-31

PHP version history (9 changes)0.1.1PHP ^7.1

1.1.x-devPHP ^7.3 || ~8.0.0

1.2.x-devPHP ^7.3 || ~8.0.0 || ~8.1.0

1.4.0PHP ^7.4 || ~8.0.0 || ~8.1.0

1.7.x-devPHP ~8.0.0 || ~8.1.0 || ~8.2.0

1.8.0PHP ~8.1.0 || ~8.2.0

1.9.0PHP ~8.1.0 || ~8.2.0 || ~8.3.0

1.10.0PHP ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0

1.11.x-devPHP ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/25943?v=4)[Matthew Weier O'Phinney](/maintainers/weierophinney)[@weierophinney](https://github.com/weierophinney)

![](https://avatars.githubusercontent.com/u/296074?v=4)[Zend Framework](/maintainers/zendframework)[@zendframework](https://github.com/zendframework)

---

Top Contributors

[![renovate[bot]](https://avatars.githubusercontent.com/in/2740?v=4)](https://github.com/renovate[bot] "renovate[bot] (198 commits)")[![michalbundyra](https://avatars.githubusercontent.com/u/7423207?v=4)](https://github.com/michalbundyra "michalbundyra (42 commits)")[![weierophinney](https://avatars.githubusercontent.com/u/25943?v=4)](https://github.com/weierophinney "weierophinney (26 commits)")[![gsteel](https://avatars.githubusercontent.com/u/2803720?v=4)](https://github.com/gsteel "gsteel (21 commits)")[![geerteltink](https://avatars.githubusercontent.com/u/9497586?v=4)](https://github.com/geerteltink "geerteltink (15 commits)")[![ghostwriter](https://avatars.githubusercontent.com/u/9754361?v=4)](https://github.com/ghostwriter "ghostwriter (11 commits)")[![Ocramius](https://avatars.githubusercontent.com/u/154256?v=4)](https://github.com/Ocramius "Ocramius (11 commits)")[![Xerkus](https://avatars.githubusercontent.com/u/725842?v=4)](https://github.com/Xerkus "Xerkus (9 commits)")[![froschdesign](https://avatars.githubusercontent.com/u/103362?v=4)](https://github.com/froschdesign "froschdesign (6 commits)")[![boesing](https://avatars.githubusercontent.com/u/2189546?v=4)](https://github.com/boesing "boesing (4 commits)")[![samsonasik](https://avatars.githubusercontent.com/u/459648?v=4)](https://github.com/samsonasik "samsonasik (3 commits)")[![kea](https://avatars.githubusercontent.com/u/208714?v=4)](https://github.com/kea "kea (1 commits)")[![hannesvdvreken](https://avatars.githubusercontent.com/u/1410358?v=4)](https://github.com/hannesvdvreken "hannesvdvreken (1 commits)")

---

Tags

hacktoberfestpsr-7laminassecuritypsr-15mezziosessioncsrf

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[mezzio/mezzio

PSR-15 Middleware Microframework

3923.8M126](/packages/mezzio-mezzio)[mezzio/mezzio-authentication-oauth2

OAuth2 (server) authentication middleware for Mezzio and PSR-7 applications.

28591.3k3](/packages/mezzio-mezzio-authentication-oauth2)[mezzio/mezzio-authentication

Authentication middleware for Mezzio and PSR-7 applications

131.7M39](/packages/mezzio-mezzio-authentication)[mezzio/mezzio-swoole

Swoole support for Mezzio

92252.0k3](/packages/mezzio-mezzio-swoole)[laminas/laminas-httphandlerrunner

Execute PSR-15 RequestHandlerInterface instances and emit responses they generate.

7219.7M289](/packages/laminas-laminas-httphandlerrunner)[sunrise/http-router

A powerful solution as the foundation of your project.

17451.6k10](/packages/sunrise-http-router)

PHPackages © 2026

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