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

ActiveLibrary[Security](/categories/security)

tramtro/m6web-firewall
======================

Library providing IP filtering features

v1.0.5(1y ago)08.2k↓30%1MITPHPPHP &gt;=5.4.0

Since May 27Pushed 1y agoCompare

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

READMEChangelog (2)Dependencies (1)Versions (10)Used By (1)

[![Latest Stable Version](https://camo.githubusercontent.com/02dc7db66c5c5c897e2a05301fb26cb0c92bc9de2e7cba07d5d17142ed14297d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7472616d74726f2f6d367765622d6669726577616c6c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tramtro/m6web-firewall)[![Total Downloads](https://camo.githubusercontent.com/2b417b1a1473728c001d572a90f6a6e05f905638026fecf09dc6b7029be1d60c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7472616d74726f2f6d367765622d6669726577616c6c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tramtro/m6web-firewall)[![Daily Downloads](https://camo.githubusercontent.com/9e7aba364af12eefb188ab71a456a918e7acd7d937fe0fb6e96a978ebeecde27/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64642f7472616d74726f2f6d367765622d6669726577616c6c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tramtro/m6web-firewall)[![Monthly Downloads](https://camo.githubusercontent.com/82e797e29cd8c31f6472d883087ce7e0e6ff94eb04162cc8fe7d32bfc31c8c40/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f7472616d74726f2f6d367765622d6669726577616c6c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tramtro/m6web-firewall)[![License](https://camo.githubusercontent.com/1118fe75c8e4a90d56b608589eb3c647326f7eb32fdf883e65523160b905ceb6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7472616d74726f2f6d367765622d6669726577616c6c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tramtro/m6web-firewall)[![PHP Version Require](https://camo.githubusercontent.com/b0c684475819bda1bc972b2d29039012262fd24f32e106eaf62411e3fa001967/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f7472616d74726f2f6d367765622d6669726577616c6c2f706870)](https://packagist.org/packages/tramtro/m6web-firewall)

Firewall by m6web
=================

[](#firewall-by-m6web)

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": {
        "tramtro/m6web-firewall": "^1.0"
    }
}
```

Update your vendors :

```
$ composer update tramtro/m6web-firewall

```

Usage
-----

[](#usage)

#### Basic usage

[](#basic-usage)

```
use nguyenanhung\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 nguyenanhung\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

37

—

LowBetter than 83% of packages

Maintenance35

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity64

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

Recently: every ~851 days

Total

9

Last Release

604d ago

Major Versions

v0.3.0 → v1.0.02015-05-20

### Community

Maintainers

![](https://www.gravatar.com/avatar/3694ef9f3367ff9f6bcd668ca1d6726e3c55e6fd379cba9c2d4ab6a24595fbd8?d=identicon)[7135k13m](/maintainers/7135k13m)

---

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)")[![hungnguyenhp](https://avatars.githubusercontent.com/u/6778496?v=4)](https://github.com/hungnguyenhp "hungnguyenhp (2 commits)")[![divinity76](https://avatars.githubusercontent.com/u/1874996?v=4)](https://github.com/divinity76 "divinity76 (2 commits)")[![nguyenanhung](https://avatars.githubusercontent.com/u/9348255?v=4)](https://github.com/nguyenanhung "nguyenanhung (1 commits)")[![fdubost](https://avatars.githubusercontent.com/u/3973818?v=4)](https://github.com/fdubost "fdubost (1 commits)")[![adriensamson](https://avatars.githubusercontent.com/u/520234?v=4)](https://github.com/adriensamson "adriensamson (1 commits)")[![b-viguier](https://avatars.githubusercontent.com/u/5537799?v=4)](https://github.com/b-viguier "b-viguier (1 commits)")[![Adel-E](https://avatars.githubusercontent.com/u/285700?v=4)](https://github.com/Adel-E "Adel-E (1 commits)")[![jubianchi](https://avatars.githubusercontent.com/u/327237?v=4)](https://github.com/jubianchi "jubianchi (1 commits)")

---

Tags

IPfilteringfirewall

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/tramtro-m6web-firewall/health.svg)](https://phpackages.com/packages/tramtro-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)
