New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

skydiver/laravel-route-blocker

Block routes by IP
92,392 80

Larablocks Analysis

skydiver/laravel-route-blocker works with any PHP project: the latest release (1.5.0, Jun 9, 2020) doesn't depend on Laravel.

Laravel 5, 6 and 7 in earlier releases.

Recommendation checks

Not advised

Not advised: no release or commit in over 2 years.

  • No release or commit in over 2 years
  • No release in the last 12 months (last: Jun 9, 2020)
  • 3,223 downloads a month (needs 10,000)
  • 80 GitHub stars (needs 100)

State

Likely abandoned
  • No release or commit in over 2 years.
  • Last stable release: Jun 9, 2020.
  • No releases in the last 12 months.
  • First released: Feb 18, 2017.
  • Monthly downloads: 3,223, up 135% from six months ago.
  • 1 open issue on GitHub.

Data from Packagist and GitHub, checked by Larablocks on Nov 26, 2026.

Install
composer require skydiver/laravel-route-blocker
Latest Version:1.5.0
PHP:>=5.4.0
Older releases:5 · 6 · 7
License:MIT
Last Updated:Sep 10, 2020
Links: GitHub  ·  Packagist
Maintainer: skydiver

Laravel Route Blocker

Block routes by IP

(inspired on Laravel Firewall)


Requirements

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


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

  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.
  1. 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)
    
  2. 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

  • 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

To manually run test suite:

vendor/bin/phpunit --verbose

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

Related Packages

laravel/wayfinder

Generate TypeScript representations of your Laravel actions and routes.

23,993,826 1,874
asbiin/laravel-webauthn

Laravel Webauthn support

778,366 310
panchodp/laravel-fingerprint

Laravel Session theft protection via client fingerprinting — auto-invalidates se...

1,212 1
cartalyst/sentinel

PHP 8.2+ Fully-featured Authentication & Authorization System

2,867,598 1,528
cline/cloak

Prevent sensitive exception details from leaking in Laravel applications

13,839 0

Version History

Version Released PHP Laravel License
1.5.0 >=5.4.0 MIT
1.4.0 >=5.4.0 >=5.1 MIT
1.3.0 >=5.4.0 >=5.1 MIT
1.2.1 >=5.4.0 >=5.1 MIT
1.2.0 >=5.4.0 >=5.1 MIT