LaravelPackages.net
Acme Inc.
Toggle sidebar
cresjie/ip-blocker

Laravel IP address blocker

40
3
v1.2.0.0
About cresjie/ip-blocker

cresjie/ip-blocker is a Laravel package for laravel ip address blocker. It currently has 3 GitHub stars and 40 downloads on Packagist (latest version v1.2.0.0). Install it with composer require cresjie/ip-blocker. Discover more Laravel packages by cresjie or browse all Laravel packages to compare alternatives.

Last updated

Laravel IP Blocker

Simple and easy to configure laravel ip blocker


Installation via Composer

Add this to your composer.json file, in the require object:

 "cresjie/ip-blocker": "v1.0.0.1"

After that, run composer install to install the package.

Add the service provider to app/config/app.php for laravel 4 and config/app.php for laravel 5, within the providers array.

 'providers' => array(
	...
	'Cresjie\IpBlocker\IpBlockerServiceProvider',
)

Configuration

Publish the default config file to your application so you can make modifications.

$ php artisan config:publish cresjie/ip-blocker

Add your block IP's to the configuration file:

 app/config/packages/cresjie/ip-blocker/config.php

Handling/Custom View

if the IP was blocked, it would throw Cresjie\IpBlocker\IpBlockerException. you could create a view by just handling the exception like this: #laravel 4

App::error(function(Exception $e){
	
	switch($e){
		case ($e instanceof \Cresjie\IpBlocker\IpBlockerException):
			return View::make('view-path');
			break;
	}
});

#laravel 5

// app/Exceptions/Handler.php

public function render($request, Exception $e)
{
	switch($e){
		case ($e instanceof \Cresjie\IpBlocker\IpBlockerException):
			return View::make('view-path');
			break;
		default:
			return parent::render($request, $e);

	}

    return parent::render($request, $e);
}

Star History Chart