PHPackages                             amonger/firewall - 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. amonger/firewall

ActiveLibrary[Security](/categories/security)

amonger/firewall
================

v0.4.1(10y ago)1382MITPHP

Since May 30Pushed 10y ago1 watchersCompare

[ Source](https://github.com/amonger/firewall)[ Packagist](https://packagist.org/packages/amonger/firewall)[ RSS](/packages/amonger-firewall/feed)WikiDiscussions master Synced 1mo ago

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

[![Build Status](https://camo.githubusercontent.com/8857f9c59ae2f1d8ca91939497fed0cc93f0332872cbe89bc28420ea8de27f7d/68747470733a2f2f7472617669732d63692e6f72672f616d6f6e6765722f6669726577616c6c2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/amonger/firewall)Firewall
=======================================================================================================================================================================================================================================================================================

[](#firewall)

This is a simple library which will have some action on a route being matched.

It is useful for legacy projects where some authorisation code my be copy pasted into a header multiple times and there is no under-laying structure.

Example
-------

[](#example)

\###Individual routes### You can define routes individually by doing the following:

```
use \amonger\Firewall\Firewall;

$firewall = new Firewall($_SERVER['REQUEST_URI']);

$firewall
    ->route('/managers\/.*/')
    ->unless(function ($uri) use ($container) {
       return $container['auth']->hasRole('manager');
    })
    ->handle(function () {
        throw new _401Exception();
    })
    ->execute();
```

\###Multiple routes### A scenario which is more likely is that you will have a single request uri and multiple routes you'd like to handle. In this case you can use the builder to setup the firewall.

```
use \amonger\Firewall\Firewall;

$firewall = Firewall::getBuilder();
$firewall->setRequestUri($_SERVER['REQUEST_URI']);

$firewall
    ->route('/managers\/.*/')
    ->unless(function ($uri) use ($container) {
       return $container['auth']->hasRole('manager');
    })
    ->handle(function () {
        throw new _401Exception();
    });

$firewall
    ->route('/clients\/.*/')
    ->unless(function ($uri) use ($container) {
       return $container['auth']->hasRole('clients');
    })
    ->handle(function () {
        throw new _401Exception();
    });

Firewall::run($firewall);
```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity57

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

Total

5

Last Release

3911d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9bfc4668b3600a449283b9375d4c111420c80fcd31e14c80ab698c7a31248823?d=identicon)[haveacigaro](/maintainers/haveacigaro)

---

Top Contributors

[![amonger](https://avatars.githubusercontent.com/u/147537?v=4)](https://github.com/amonger "amonger (10 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/amonger-firewall/health.svg)

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

###  Alternatives

[defuse/php-encryption

Secure PHP Encryption Library

3.9k162.4M214](/packages/defuse-php-encryption)[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

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

Realistic password strength estimation PHP library based on Zxcvbn JS

87117.5M63](/packages/bjeavons-zxcvbn-php)[illuminate/encryption

The Illuminate Encryption package.

9229.7M280](/packages/illuminate-encryption)[paragonie/hidden-string

Encapsulate strings in an object to hide them from stack traces

7410.6M39](/packages/paragonie-hidden-string)

PHPackages © 2026

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