PHPackages                             skydiver/laravel-route-blocker - 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. skydiver/laravel-route-blocker

ActiveLibrary[Security](/categories/security)

skydiver/laravel-route-blocker
==============================

Block routes by IP

1.5.0(6y ago)8276.1k↓39.1%11[1 issues](https://github.com/skydiver/laravel-route-blocker/issues)MITPHPPHP &gt;=5.4.0CI failing

Since Feb 18Pushed 5y ago3 watchersCompare

[ Source](https://github.com/skydiver/laravel-route-blocker)[ Packagist](https://packagist.org/packages/skydiver/laravel-route-blocker)[ Docs](https://github.com/skydiver/laravel-route-blocker)[ RSS](/packages/skydiver-laravel-route-blocker/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (3)Versions (9)Used By (0)

Laravel Route Blocker
=====================

[](#laravel-route-blocker)

Block routes by IP

*(inspired on [Laravel Firewall](https://github.com/antonioribeiro/firewall))*

---

Requirements
------------

[](#requirements)

Laravel 5.x, 6.x, 7.x and 8.x

---

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

[](#installation)

1. To install through composer, run the following command from terminal:

    ```
    $ composer require skydiver/laravel-route-blocker
    ```
2. Publish the config file:

    Run the following command to publish the package config file:

    ```
    $ php artisan vendor:publish --tag=LaravelRouteBlocker
    ```

Still using Laravel 5.4 or below?Please add service provider to your `config/app.php` providers array:

```
'providers' => [
    ...
    Skydiver\LaravelRouteBlocker\LaravelRouteBlockerServiceProvider::class,
]
```

---

Usage
-----

[](#usage)

1. Register middlewares in `app/Http/Kernel.php` on `$routeMiddleware` array: ```
        'blacklist' => \Skydiver\LaravelRouteBlocker\Middleware\BlacklistMiddleware::class,
        'whitelist' => \Skydiver\LaravelRouteBlocker\Middleware\WhitelistMiddleware::class,

    ```

- Blacklist allows all traffic except matching rules.
- Whitelist blocks all traffic except matching rules.
- You can register both or just a single middleware.

2. Create a config group on `config/laravel-route-blocker.php` and insert your allowed/blocked IPs:

    ```
        'whitelist' => [
            'my_group' => [
                '127.0.0.1',
                '192.168.17.0',
                '10.0.1.*'
            ],
            'another_group' => [
                '8.8.8.*'
            ],
        ],
        'blacklist' => [
            'blocked_ips' => [
                '127.0.0.1',
                '192.168.100.0',
            ],
            'blocked_ips2' => [
                '8.8.8.8',
            ],
        ],

    ```

    - You can create as many blacklist/whitelists groups as you wish and protect differents set of routes with differents IPs

    Also, you can configure to throw an HTTP status code or redirect to a custom URL:

    ```
    'redirect_to'      => '',   // URL TO REDIRECT IF BLOCKED (LEAVE BLANK TO THROW STATUS)
    'response_status'  => 403,  // STATUS CODE (403, 404 ...)
    'response_message' => ''    // MESSAGE (COMBINED WITH STATUS CODE)

    ```
3. Put your protected routes inside a group and specify the whitelist parameter:

    ```
        // Only IPs matched on "my_group" will be allowed to access route
        Route::group(['middleware' => 'whitelist:my_group'], function() {

            Route::get('/demo', function () {
                return "DEMO";
            });

        });

        // Only IPs matched on "my_group" will be blocked to access route
        Route::group(['middleware' => 'blacklist:blocked_ips'], function() {

            Route::get('/private', function () {
                return "Private Page";
            });

        });

    ```

---

Artisan Commands
----------------

[](#artisan-commands)

- To get a list of current IPs groups run:

    ```
        $ php artisan route:blocks:groups

    ```

    ```
        +-----------------+--------------+-----------+
        | Group           | IP           | Type      |
        +-----------------+--------------+-----------+
        | allowed_group_1 | 127.0.0.1    | whitelist |
        | allowed_group_1 | 127.0.0.2    | whitelist |
        | allowed_group_1 | 192.168.17.0 | whitelist |
        | allowed_group_1 | 10.0.0.*     | whitelist |
        | allowed_group_2 | 8.8.8.8      | whitelist |
        | allowed_group_2 | 8.8.8.*      | whitelist |
        | allowed_group_2 | 8.8.4.4      | whitelist |
        | blocked_ips_1   | 127.0.0.1    | blacklist |
        | blocked_ips_1   | 127.0.0.2    | blacklist |
        | blocked_ips_1   | 192.168.17.0 | blacklist |
        | blocked_ips_1   | 10.0.0.*     | blacklist |
        | blocked_ips_2   | 8.8.8.8      | blacklist |
        | blocked_ips_2   | 8.8.8.*      | blacklist |
        | blocked_ips_2   | 8.8.4.4      | blacklist |
        +-----------------+--------------+-----------+

    ```

---

Testing
-------

[](#testing)

To manually run test suite:

```
vendor/bin/phpunit --verbose

```

Test files inside `tests/Feature` should be run by GitHub action only.

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity45

Moderate usage in the ecosystem

Community17

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 81.5% 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 ~172 days

Recently: every ~211 days

Total

8

Last Release

2217d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6b28541f1ac1be505a155d5800c252643bf7ca4f8266e10fc6a83864889003bc?d=identicon)[skydiver](/maintainers/skydiver)

---

Top Contributors

[![skydiver](https://avatars.githubusercontent.com/u/578784?v=4)](https://github.com/skydiver "skydiver (22 commits)")[![theschwag](https://avatars.githubusercontent.com/u/1228386?v=4)](https://github.com/theschwag "theschwag (2 commits)")[![bogvsdev](https://avatars.githubusercontent.com/u/9955551?v=4)](https://github.com/bogvsdev "bogvsdev (1 commits)")[![itbm](https://avatars.githubusercontent.com/u/22393016?v=4)](https://github.com/itbm "itbm (1 commits)")[![tai1030](https://avatars.githubusercontent.com/u/16300420?v=4)](https://github.com/tai1030 "tai1030 (1 commits)")

---

Tags

firewallip-blacklistlaravellaravel-packagesphpsecurityphplaravelroutessecurityblock

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/skydiver-laravel-route-blocker/health.svg)

```
[![Health](https://phpackages.com/badges/skydiver-laravel-route-blocker/health.svg)](https://phpackages.com/packages/skydiver-laravel-route-blocker)
```

###  Alternatives

[tzsk/otp

A secure, database-free One-Time Password (OTP) generator and verifier for PHP and Laravel.

244672.1k1](/packages/tzsk-otp)

PHPackages © 2026

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