PHPackages                             msallehi/php-geolocation - 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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. msallehi/php-geolocation

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

msallehi/php-geolocation
========================

A PHP package to restrict access based on user's country/IP location - Works with Laravel, WordPress, and pure PHP

v1.2.1(4mo ago)1483↓66.7%MITPHPPHP ^8.0

Since Dec 1Pushed 4mo agoCompare

[ Source](https://github.com/MSallehi/php-geolocation)[ Packagist](https://packagist.org/packages/msallehi/php-geolocation)[ RSS](/packages/msallehi-php-geolocation/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (2)Versions (5)Used By (0)

PHP GeoLocation - IP/Country Restriction Package
================================================

[](#php-geolocation---ipcountry-restriction-package)

[![Latest Version on Packagist](https://camo.githubusercontent.com/c6452932c491aec19490010ca325f0daee8e294c6b40bd8ff89c352448d78465/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d73616c6c6568692f7068702d67656f6c6f636174696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/msallehi/php-geolocation)[![Total Downloads](https://camo.githubusercontent.com/96c164b0f8e256036af228c26e9a4ca4fb1aa6a9c09c2e6147a532dbf61ca2a7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d73616c6c6568692f7068702d67656f6c6f636174696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/msallehi/php-geolocation)[![License](https://camo.githubusercontent.com/9b0b559e67fa14c0d2a60edecc826e895f37b817945f662a6338a1c081218e91/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6d73616c6c6568692f7068702d67656f6c6f636174696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/msallehi/php-geolocation)[![PHP Version](https://camo.githubusercontent.com/1c1746a22d97d292d5ea3f36677c880b2684c8b7ad88bb721285dfe042441a53/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6d73616c6c6568692f7068702d67656f6c6f636174696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/msallehi/php-geolocation)

A PHP package to restrict user access based on their country/IP location. **Works with pure PHP, Laravel, WordPress, and any PHP framework.**

 [🇮🇷 مستندات فارسی](./README.fa.md) | [📋 Changelog](./CHANGELOG.md)

✨ Features
----------

[](#-features)

- 🌍 Automatic country detection from IP address
- 🔒 Restrict access to specific countries
- ⚙️ Fully customizable configuration
- 🔧 Multiple API provider support
- 📝 Custom error messages
- 🔄 Automatic fallback when API fails (v1.1.0+)
- 🎯 Compatible with pure PHP, Laravel, and WordPress

📦 Installation
--------------

[](#-installation)

```
composer require msallehi/php-geolocation
```

🚀 Quick Start
-------------

[](#-quick-start)

### Pure PHP

[](#pure-php)

```
