PHPackages                             avcodewizard/block-by-country - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. avcodewizard/block-by-country

ActiveLibrary

avcodewizard/block-by-country
=============================

1.0.1(1y ago)861[1 issues](https://github.com/avcodewizard/block-by-country/issues)MITPHPPHP ^7.3|^8.0

Since Oct 24Pushed 1y ago1 watchersCompare

[ Source](https://github.com/avcodewizard/block-by-country)[ Packagist](https://packagist.org/packages/avcodewizard/block-by-country)[ RSS](/packages/avcodewizard-block-by-country/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)DependenciesVersions (3)Used By (0)

[![Laravel Logo](https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg)](https://laravel.com)

Block By Country Laravel Package
================================

[](#block-by-country-laravel-package)

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

Features
--------

[](#features)

- Block access to your Laravel app based on country.
- Using [ipinfo.io](https://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
------------

[](#installation)

### Step 1: Install the package via Composer

[](#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

[](#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

[](#step-3-update-configblockbycountryphp)

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

[](#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
------------

[](#requirements)

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

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

571d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1e19e6c2cab30c60bcd1f9c6794710aafef9703dccbfb59b346e3f648ca799a9?d=identicon)[avcodewizard](/maintainers/avcodewizard)

---

Top Contributors

[![avcodewizard](https://avatars.githubusercontent.com/u/45030401?v=4)](https://github.com/avcodewizard "avcodewizard (3 commits)")

---

Tags

laravellaravel-frameworklaravel-packagelaravel11

### Embed Badge

![Health badge](/badges/avcodewizard-block-by-country/health.svg)

```
[![Health](https://phpackages.com/badges/avcodewizard-block-by-country/health.svg)](https://phpackages.com/packages/avcodewizard-block-by-country)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
