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

AbandonedArchivedLibrary[Security](/categories/security)

m6web/firewall
==============

Library providing IP filtering features

v1.0.3(6y ago)62737.8k—5.5%24[5 issues](https://github.com/M6Web/Firewall/issues)8MITPHPPHP &gt;=5.4.0

Since May 27Pushed 6y ago34 watchersCompare

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

READMEChangelog (4)Dependencies (1)Versions (8)Used By (8)

Firewall [![Build Status](https://camo.githubusercontent.com/8e8006abdf97a5bac94fc3008e24f23d64b37a3930bd84de358e249f735b9e2d/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f4d365765622f4669726577616c6c2e706e67)](http://travis-ci.org/M6Web/Firewall)
===================================================================================================================================================================================================================================================================

[](#firewall-)

This PHP 5.4+ library provides IP filtering features.
A lot of [filters](#entries-formats) can be used.
It is also possible to [customize](#custom-error-handling) the error handling.

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

[](#installation)

Add this line in your `composer.json` :

```
{
    "require": {
        "m6web/firewall": "dev-master"
    }
}
```

Update your vendors :

```
$ composer update m6web/firewall

```

Usage
-----

[](#usage)

#### Basic usage

[](#basic-usage)

```
use M6Web\Component\Firewall\Firewall;

$whiteList = array(
    '127.0.0.1',
    '192.168.0.*',
);

$blackList = array(
    '192.168.0.50',
);

$firewall = new Firewall();

$connAllowed = $firewall
    ->setDefaultState(false)
    ->addList($whiteList, 'local', true)
    ->addList($blackList, 'localBad', false)
    ->setIpAddress('195.88.195.146')
    ->handle()
;

if (!$connAllowed) {
    http_response_code(403); // Forbidden
    exit();
}
```

In this example, only IPs starting with *192.168.0* (but not *192.168.0.50*) and *127.0.0.1* will be allowed by the firewall.
In all other case `handle()` return false.

- `setDefaultState(false)` defines default firewall response (Optional - Default false),
- `addList($whiteList, 'local', true)` defines `$whiteList` list, called `local` as allowed (`true`),
- `addList($blackList, 'localBad', false);` defines `$blackList` list, called `localBad` as rejected (`false`).

#### Entries Formats

[](#entries-formats)

TypeSyntaxDetailsIPV6`::1`Short notationIPV4`192.168.0.1`Range`192.168.0.0-192.168.1.60`Includes all IPs from *192.168.0.0* to *192.168.0.255*
and from *192.168.1.0* to *198.168.1.60*Wild card`192.168.0.*`IPs starting with *192.168.0*
Same as IP Range `192.168.0.0-192.168.0.255`Subnet mask`192.168.0.0/255.255.255.0`IPs starting with *192.168.0*
Same as `192.168.0.0-192.168.0.255` and `192.168.0.*`CIDR Mask`192.168.0.0/24`IPs starting with *192.168.0*
Same as `192.168.0.0-192.168.0.255` and `192.168.0.*`
and `192.168.0.0/255.255.255.0`#### Custom error handling

[](#custom-error-handling)

```
use M6Web\Component\Firewall\Firewall;

function handleFirewallReturn(Firewall $firewall, $response) {
    if (false === $response) {
        header($_SERVER["SERVER_PROTOCOL"]." 403 Forbiden");
        exit();
    }

    return $response;
}

$whiteList = array(
    '127.0.0.1',
    '198.168.0.*',
);

$blackList = array(
    '192.168.0.50',
);

$firewall = new Firewall();
$firewall
    ->setDefaultState(true)
    ->addList($whiteList, 'local', true)
    ->addList($blackList, 'localBad', false)
    ->setIpAddress('195.88.195.146')
    ->handle('handleFirewallReturn')
;
```

`handle('handleFirewallReturn')` calls `handleFirewallReturn` with Firewall object and response as arguments (true or false).

Running the tests
-----------------

[](#running-the-tests)

```
$ php composer.phar install --dev
$ ./vendor/bin/atoum -d Tests
```

Credits
-------

[](#credits)

Developped by the [Cytron Team](http://cytron.fr/) of [M6 Web](http://tech.m6web.fr/).
Tested with [atoum](http://atoum.org).

License
-------

[](#license)

Firewall is licensed under the [MIT license](LICENSE).

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity50

Moderate usage in the ecosystem

Community34

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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

Recently: every ~524 days

Total

7

Last Release

2407d ago

Major Versions

v0.3.0 → v1.0.02015-05-20

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2069361?v=4)[Patrick](/maintainers/Bedrock)[@Bedrock](https://github.com/Bedrock)

![](https://avatars.githubusercontent.com/u/5537799?v=4)[Benoit](/maintainers/b-viguier)[@b-viguier](https://github.com/b-viguier)

---

Top Contributors

[![KuiKui](https://avatars.githubusercontent.com/u/748924?v=4)](https://github.com/KuiKui "KuiKui (14 commits)")[![omansour](https://avatars.githubusercontent.com/u/1131098?v=4)](https://github.com/omansour "omansour (10 commits)")[![dipston](https://avatars.githubusercontent.com/u/4101731?v=4)](https://github.com/dipston "dipston (7 commits)")[![divinity76](https://avatars.githubusercontent.com/u/1874996?v=4)](https://github.com/divinity76 "divinity76 (2 commits)")[![Adel-E](https://avatars.githubusercontent.com/u/285700?v=4)](https://github.com/Adel-E "Adel-E (1 commits)")[![fdubost](https://avatars.githubusercontent.com/u/3973818?v=4)](https://github.com/fdubost "fdubost (1 commits)")[![jubianchi](https://avatars.githubusercontent.com/u/327237?v=4)](https://github.com/jubianchi "jubianchi (1 commits)")[![b-viguier](https://avatars.githubusercontent.com/u/5537799?v=4)](https://github.com/b-viguier "b-viguier (1 commits)")[![adriensamson](https://avatars.githubusercontent.com/u/520234?v=4)](https://github.com/adriensamson "adriensamson (1 commits)")

---

Tags

IPfilteringfirewall

### Embed Badge

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

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

###  Alternatives

[pragmarx/firewall

A Laravel IP whitelisting and blacklisting

1.4k988.9k](/packages/pragmarx-firewall)[akaunting/laravel-firewall

Web Application Firewall (WAF) package for Laravel

999465.8k2](/packages/akaunting-laravel-firewall)[shieldon/shieldon

Web application firewall for PHP.

87328.2k1](/packages/shieldon-shieldon)[mchev/banhammer

Banhammer for Laravel allows you to ban any Model by key and by IP.

36693.4k2](/packages/mchev-banhammer)[jeroenvisser101/leakybucket

An implementation of the Leaky Bucket algorithm.

44116.6k](/packages/jeroenvisser101-leakybucket)[websoftwares/throttle

Ban identifier after certain amount of requests in a given timeframe.

1249.7k](/packages/websoftwares-throttle)

PHPackages © 2026

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