PHPackages                             alsar/stack-ip-restrict - 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. alsar/stack-ip-restrict

ActiveLibrary[Security](/categories/security)

alsar/stack-ip-restrict
=======================

Stack middleware for allowing application access for specific IP addresses

v1.0.1(8y ago)314.9k6[1 issues](https://github.com/alsar/stack-ip-restrict/issues)MITPHPPHP &gt;=5.4

Since Jul 19Pushed 8y ago2 watchersCompare

[ Source](https://github.com/alsar/stack-ip-restrict)[ Packagist](https://packagist.org/packages/alsar/stack-ip-restrict)[ RSS](/packages/alsar-stack-ip-restrict/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (5)Versions (4)Used By (0)

IpRestrict Stack middleware
===========================

[](#iprestrict-stack-middleware)

[Stack](http://stackphp.com) middleware to restrict application access for specific IP addresses.

Usage
-----

[](#usage)

### Silex example

[](#silex-example)

```
require __DIR__ . '/../vendor/autoload.php';

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Alsar\Stack\IpRestrict;

$app = new Silex\Application();

$app->get('/', function(Request $request) {
    return new Response('Hello world!', 200);
});

$app = (new Stack\Builder())
    ->push('Alsar\Stack\IpRestrict', ['127.0.0.1'])
    ->resolve($app)
;

$request = Request::createFromGlobals();
$response = $app->handle($request)->send();

$app->terminate($request, $response);
```

### Symfony example

[](#symfony-example)

```
# web/app_dev.php

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Debug\Debug;

$loader = require_once __DIR__.'/../app/bootstrap.php.cache';
Debug::enable();

require_once __DIR__.'/../app/AppKernel.php';

$kernel = new AppKernel('dev', true);
$kernel->loadClassCache();

$stack = (new Stack\Builder())
    ->push('Alsar\Stack\IpRestrict', ['127.0.0.1', 'fe80::1', '::1']);

$kernel = $stack->resolve($kernel);

Request::enableHttpMethodParameterOverride();
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
```

Intallation
-----------

[](#intallation)

The recommended way to install this library is through [Composer](http://getcomposer.org/):

```
{
    "require": {
        "alsar/stack-ip-restrict": "~1.0"
    }
}
```

License
-------

[](#license)

This library is released under the MIT License. See the bundled LICENSE file for details.

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 50% 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 ~814 days

Total

3

Last Release

3055d ago

Major Versions

v0.1 → v1.0.02014-02-12

### Community

Maintainers

![](https://www.gravatar.com/avatar/7e1373d3ece173731b9d3c84315ad4a2dc1965a43f3e87bb9efb2088d13f01d8?d=identicon)[alsar](/maintainers/alsar)

---

Top Contributors

[![glensc](https://avatars.githubusercontent.com/u/199095?v=4)](https://github.com/glensc "glensc (1 commits)")[![simensen](https://avatars.githubusercontent.com/u/191200?v=4)](https://github.com/simensen "simensen (1 commits)")

---

Tags

stackip restrictstack middleware

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/alsar-stack-ip-restrict/health.svg)

```
[![Health](https://phpackages.com/badges/alsar-stack-ip-restrict/health.svg)](https://phpackages.com/packages/alsar-stack-ip-restrict)
```

###  Alternatives

[tilleuls/url-signer-bundle

Create and validate signed URLs with a limited lifetime in Symfony

81340.1k](/packages/tilleuls-url-signer-bundle)[dneustadt/csrf-cookie-bundle

CSRF protection cookie for use with XHR

1379.2k1](/packages/dneustadt-csrf-cookie-bundle)

PHPackages © 2026

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