Download the PHP package effilib/laravel-restrict-ip-middleware without Composer
On this page you can find all versions of the php package effilib/laravel-restrict-ip-middleware. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download effilib/laravel-restrict-ip-middleware
More information about effilib/laravel-restrict-ip-middleware
Files in effilib/laravel-restrict-ip-middleware
Package laravel-restrict-ip-middleware
Short Description A Laravel package to restrict access by IP addresses, CIDR ranges, route names, or URI patterns.
License MIT
Informations about the package laravel-restrict-ip-middleware
Laravel Restrict IP Middleware
A Laravel middleware package to restrict access based on:
- Exact IP addresses
- CIDR ranges
- Route names (supports wildcards)
- URI patterns
This allows you to secure sensitive areas of your application, while still defining exception rules (whitelisted routes or URIs that always stay accessible).
๐ฆ Installation
Install via Composer:
Laravel will auto-discover the service provider.
โ๏ธ Publish Configuration
Publish the configuration file:
This will create:
๐ Usage
Apply the middleware to routes or groups.
Default ruleset
Custom ruleset
The middleware parameter (:custom) selects which ruleset from effilib-restrict-ip.php to apply.
๐ Configuration
Example config/effilib-restrict-ip.php:
๐ How it works
The middleware checks in this order:
- Allowed route names โ if matched, always allowed
- Allowed URI patterns โ if matched, always allowed
- Exact IP addresses โ if matched, allowed
- CIDR ranges โ if matched, allowed
- Otherwise denied โ returns configured error code (default:
403)
๐งช Example
With this setup:
/adminand/settingsrequire a matching IP or CIDR
๐ License
MIT License ยฉ Effilib