michaelnabil230/laravel-block-ip
Composer 安装命令:
composer require michaelnabil230/laravel-block-ip
包简介
This package is for controlling everything related to website visits using the Laravel framework
README 文档
README
The Laravel Block IP package provides a convenient way to control everything related to website visits using the Laravel framework. It allows you to block specific IP addresses, configure rate limiting, and receive notifications for certain events.
Installation
You can install the package via Composer by running the following command:
composer require michaelnabil230/laravel-block-ip
After installing the package, you need to publish the package files and run the migrations:
php artisan block-ip:install php artisan migrate
To publish and run the migrations separately, you can use the following commands:
php artisan vendor:publish --tag="laravel-block-ip-migrations"
php artisan migrate
You can also publish the package's configuration file using the following command:
php artisan vendor:publish --tag="laravel-block-ip-config"
The published configuration file allows you to customize various settings related to block IP functionality, notifications, caching, and more.
Usage
To configure rate limiting and use the package's functionality, you can add code to your app/Providers/RouteServiceProvider.php file. The following code demonstrates how to configure rate limiting and enable the package:
protected function configureRateLimiting() { RateLimiter::for('api', function (Request $request) { return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip()); }); \MichaelNabil230\BlockIp\BlockIpRegistrar::rateLimiter(); }
By default, the rate limiter is set to allow 60 requests per minute, but you can customize this value by passing it to the rateLimiter() method.
The package provides a BlockIpMiddleware middleware that you can add to your routes in the app/Http/Kernel.php file. Make sure to uncomment the necessary line for the throttle middleware as well. Here's an example:
protected $middlewareAliases = [ // ... 'block-ip' => \MichaelNabil230\BlockIp\Middleware\BlockIpMiddleware::class, ];
To protect your routes using the block IP middleware and rate limiting, you can define them as follows:
Route::middleware(['block-ip', 'throttle:block-ip'])->group(function () { // Your protected routes here });
If you want to unblock all IP addresses, you can use the following command:
php artisan block-ip:unblock --all
You can also unblock multiple IP addresses by providing them as a comma-separated list:
php artisan block-ip:unblock --ips=127.0.0.1,127.0.0.2
To block new IP addresses, you can use the following command:
php artisan block-ip:block 127.0.0.1 127.0.0.2
Support
If you find this package useful, you can show your support by contributing financially:
Testing
You can run the package's tests using the following command:
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.
michaelnabil230/laravel-block-ip 适用场景与选型建议
michaelnabil230/laravel-block-ip 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 174 次下载、GitHub Stars 达 5, 最近一次更新时间为 2022 年 10 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「MichaelNabil230」 「laravel-block-ip」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 michaelnabil230/laravel-block-ip 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 michaelnabil230/laravel-block-ip 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 michaelnabil230/laravel-block-ip 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Package for get the weather data
This package allows you to persists setting for Laravel projects.
Alfabank REST API integration
This is my package greet
Package for get the weather data
Automatic multi-tenancy for your Laravel application.
统计信息
- 总下载量: 174
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 16
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-10-19


