PHPackages                             pkj/minibase-plugin-csrfprotection - 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. pkj/minibase-plugin-csrfprotection

ActiveLibrary

pkj/minibase-plugin-csrfprotection
==================================

Plugin that enabled CSRF Protection by default for Minibase framework apps.

024

Since Apr 26Compare

[ Source](https://github.com/peec/minibase-plugin-csrfprotection)[ Packagist](https://packagist.org/packages/pkj/minibase-plugin-csrfprotection)[ RSS](/packages/pkj-minibase-plugin-csrfprotection/feed)WikiDiscussions Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

[![Build Status](https://camo.githubusercontent.com/920768c9a20f0d71ff5a85f3c4d08b3d25894b79e5b2419b0fe26c517c58e10c/68747470733a2f2f7472617669732d63692e6f72672f706565632f6d696e69626173652d706c7567696e2d6373726670726f74656374696f6e2e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/peec/minibase-plugin-csrfprotection)

CSRF Protection Plugin
======================

[](#csrf-protection-plugin)

CSRF Protection plugin for [Minibase](http://github.com/peec/minibase) applications.

Handle evil CSRF attacks for all your routes except GET.

Install
-------

[](#install)

```
{
  "require":{
	     "pkj/minibase-plugin-csrfprotection": "dev-master"
	}
}
```

Usage
-----

[](#usage)

Add the plugin to your app.

```
$mb->initPlugins(array('Pkj\Minibase\Plugin\Csrf\CsrfPlugin' => null));
```

Echo `$csrfTokenInput` in the forms that does post requests. Note, also `$csrfToken` is available, it contains only the token.

```

```

You are now safe for CSRF protection.

Configuration array:
--------------------

[](#configuration-array)

- store: `cookie` or `session`. Note SESSION must be started if session is used. I recommend using `cookie`.
- token\_name: the name of the token. Default is "csrfToken".

Events
------

[](#events)

You may customize the error exception if a token is invalid by adding event handler.

```
$mb->events->on("csrf:invalid", function ($request) {
	return function () {
		return $this->respond("html")->view("csrfinvalid.html.php");
	};
});
```

Annotations
-----------

[](#annotations)

First, use the class . `use Pkj\Minibase\Plugin\Csrf\Annotation\IgnoreCsrfProtection`.

#### @IgnoreCsrfProtection

[](#ignorecsrfprotection)

Can be applied to controllers or a controller method. Useful for RESTful API's. (JSON API). In such where we do not need to check for CSRF protection.

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/88b748fa2f0dcacab307a6305e98032de7adb93f955bbaf3c6fe029a7369ac84?d=identicon)[peec](/maintainers/peec)

---

Top Contributors

[![peec](https://avatars.githubusercontent.com/u/131546?v=4)](https://github.com/peec "peec (16 commits)")

### Embed Badge

![Health badge](/badges/pkj-minibase-plugin-csrfprotection/health.svg)

```
[![Health](https://phpackages.com/badges/pkj-minibase-plugin-csrfprotection/health.svg)](https://phpackages.com/packages/pkj-minibase-plugin-csrfprotection)
```

PHPackages © 2026

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