承接 avcodewizard/block-by-country 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

avcodewizard/block-by-country

最新稳定版本:1.0.1

Composer 安装命令:

composer require avcodewizard/block-by-country

包简介

README 文档

README

Laravel Logo

Block By Country Laravel Package

A simple Laravel package to block your application access by country.

Features

  • Block access to your Laravel app based on country.
  • Using ipinfo.io to detect the user's country by their IP address.
  • Easy configuration of blocked countries.
  • Middleware-based approach, so it’s flexible and extendable.

Installation

Step 1: Install the package via Composer

You can install this package via Composer by running the following command in your Laravel project:

composer require avcodewizard/block-by-country

Step 2: Publish the configuration file

The package includes a configuration file where you can define which countries to block. The configuration file will be automatically published to your Laravel app. However, if you need to update or publish it manually, you can run:

php artisan vendor:publish --provider="Avcodewizard\BlockByCountry\BlockByCountryServiceProvider" --tag="config"

Step 3: Update config/blockbycountry.php

In the configuration file config/blockbycountry.php, you can specify the ISO country codes that you want to block.

return [
    'blocked_countries' => ['CN', 'RU', 'IR'], // Add country codes to block here.
];

Step 4: Add Middleware to Routes

To block specific routes based on the user's country, simply apply the middleware block.country to any route or route group.

Route::get('/dashboard', function () {
    return view('dashboard');
})->middleware('block.country');

OR

Route::group(['middleware' => 'block.country'], function () {

    Route::get('/dashboard', function () {
        return view('dashboard');
    });

    // put all your routes inside this group ...
});

Requirements

  • PHP 7.4 or higher
  • Laravel 8.x or higher

统计信息

  • 总下载量: 62
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 8
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 8
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-10-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固