Download the PHP package olssonm/blockip without Composer
On this page you can find all versions of the php package olssonm/blockip. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download olssonm/blockip
More information about olssonm/blockip
Files in olssonm/blockip
Package blockip
Short Description Block requests from specified IPs in Laravel 5.
License MIT
Homepage https://github.com/olssonm/blockip
Informations about the package blockip
Blockip
Block requests from specified IPs quick and easy in Laravel. Highly customizable.
Version Compatibility
Laravel | blockip |
---|---|
5.3.x | 1.x.x |
5.4.x | 2.x.x |
5.5/5.6/5.7/5.8 | 3.x.x |
^6.0 | 4.x.x |
^7.0 | 5.x.x |
^8.0 | 6.x.x |
Installation
Via Composer
Add the service provider to the providers array in config/app.php
(auto-detection also available in newer Laravel-versions).
Usage
This backage sets up the blockip
-middleware for use in your application. All routes that uses the middlareware is protected from unwanted requests.
Use in a group
Singe route
Configuration
Run the command $ php artisan vendor:publish --provider="Olssonm\Blockip\BlockipServiceProvider"
to publish the packages configuration. In config/blockip.php
you can edit your settings:
Everything here is pretty much self explanatory, but because the blockip-handler is customizable you can pretty much change every aspect of the middleware.
If you want to write your own handler, you should implement the Olssonm\Blockip\Handlers\BaseHandler
-interface, like so:
Using the system you have the ability to for example make your getIpsToBlock()
-method check IPs from an API, your getError()
return a JSON-response etc. etc.
Note: the default handler already checks for the special HTTP_CF_CONNECTING_IP
-header when using the Cloudflare CDN.
Testing
or
Laravel always runs in the "testing" environment while running tests. Make sure that testing
is set in the envs
-array in blockip.php
.
License
The MIT License (MIT). Please see License File for more information.
© 2021 Marcus Olsson.