Download the PHP package msallehi/php-geolocation without Composer
On this page you can find all versions of the php package msallehi/php-geolocation. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download msallehi/php-geolocation
More information about msallehi/php-geolocation
Files in msallehi/php-geolocation
Package php-geolocation
Short Description A PHP package to restrict access based on user's country/IP location - Works with Laravel, WordPress, and pure PHP
License MIT
Informations about the package php-geolocation
PHP GeoLocation - IP/Country Restriction Package
A PHP package to restrict user access based on their country/IP location. Works with pure PHP, Laravel, WordPress, and any PHP framework.
🇮🇷 مستندات فارسی | 📋 Changelog
✨ 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
🚀 Quick Start
Pure PHP
Static Factory
📖 Full Documentation
Basic Usage
Exception Handling
Dynamic Configuration
Check Specific IP
🔵 Laravel Integration
Register Service Provider
In config/app.php:
Publish Config
Using Middleware
Using Facade
🟢 WordPress Integration
Basic Setup
In your theme's functions.php or plugin:
Using Helper Functions
Using Shortcode
Restrict Entire Page
Custom Restriction in Template
🌐 API Providers
ip-api (Default - Free)
ip-api.ir (Iranian API - Recommended for Iranian Servers) 🇮🇷
Optimized for servers located in Iran. Works reliably when international APIs might be slow or blocked.
📍 Tip: If your server is in Iran, use
ip-api-iras the primary provider andip-apias fallback:
ipinfo.io
ipdata.co
⚙️ Full Configuration
📝 Custom Error Messages
In Constructor
Runtime
With denyAccess
📋 Country Codes
Use ISO 3166-1 alpha-2 codes:
| Country | Code |
|---|---|
| Iran | IR |
| United States | US |
| United Kingdom | GB |
| Germany | DE |
| France | FR |
| Turkey | TR |
| Canada | CA |
| Australia | AU |
| UAE | AE |
| Saudi Arabia | SA |
📄 License
The MIT License (MIT). Please see License File for more information.
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
👨💻 Author
- Mohammad Salehi - GitHub
⭐ Support
If you find this package useful, please give it a star on GitHub!