PHPackages                             magefan/module-geoip - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. magefan/module-geoip

ActiveMagento2-module[Utility &amp; Helpers](/categories/utility)

magefan/module-geoip
====================

Allows to get country code by IP

2.3.5(7mo ago)55232.8k—0.8%131PHP

Since Jan 24Pushed 3mo ago2 watchersCompare

[ Source](https://github.com/magefan/module-geoip)[ Packagist](https://packagist.org/packages/magefan/module-geoip)[ RSS](/packages/magefan-module-geoip/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (34)Used By (1)

Magento 2 GeoIP Database Extension by Magefan
=============================================

[](#magento-2-geoip-database-extension-by-magefan)

[![Total Downloads](https://camo.githubusercontent.com/fbb63d6bc938810368ac3fdd9a8deba523975d07a30150b93746c86df9f5492d/68747470733a2f2f706f7365722e707567782e6f72672f6d61676566616e2f6d6f64756c652d67656f69702f646f776e6c6f616473)](https://packagist.org/packages/magefan/module-geoip)[![Latest Stable Version](https://camo.githubusercontent.com/d2ad3978b05ad80ba16b8c34a4a11b45c5998c2f462a1aa75aa4cb61a4b62526/68747470733a2f2f706f7365722e707567782e6f72672f6d61676566616e2f6d6f64756c652d67656f69702f762f737461626c65)](https://packagist.org/packages/magefan/module-geoip)

[![](https://camo.githubusercontent.com/db05aa38c774e1bb774896216b5616ff981666aa71c7959d703cdd113e890e54/68747470733a2f2f6d61676566616e2e636f6d2f6d656469612f777973697779672f6d6164655f696e5f756b7261696e652e6a7067)](https://camo.githubusercontent.com/db05aa38c774e1bb774896216b5616ff981666aa71c7959d703cdd113e890e54/68747470733a2f2f6d61676566616e2e636f6d2f6d656469612f777973697779672f6d6164655f696e5f756b7261696e652e6a7067)

This Magento 2 GeoIP module provides you PHP methods for getting customer country by IP, without any additional plugin for PHP.

It is used for [Magento 2 Currency Auto Switcher](https://magefan.com/magento-2-currency-switcher-auto-currency-by-country) and [Magento 2 Auto Language Switcher](https://magefan.com/magento-2-auto-language-switcher) by Magefan

🇺🇦 Stand with Ukraine! [How can you help?](https://magefan.com/blog/join-our-donations)
---------------------------------------------------------------------------------------

[](#-stand-with-ukraine-how-can-you-help)

Requirements
------------

[](#requirements)

- Magento Community Edition 2.0.x-2.4.x or Magento Enterprise Edition 2.0.x-2.4.x

Installation Method 1 - Installing via composer
-----------------------------------------------

[](#installation-method-1---installing-via-composer)

- Open command line
- Using command "cd" navigate to your magento2 root directory
- Run command: composer require magefan/module-geoip

```
composer require magefan/module-geoip
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy

```

Installation Method 2 - Installing using archive
------------------------------------------------

[](#installation-method-2---installing-using-archive)

- Install GeoIP2 PHP API ().
- Download [ZIP Archive](https://github.com/magefan/module-geoip/archive/master.zip)
- Extract files
- In your Magento 2 root directory create folder app/code/Magefan/GeoIp
- Copy files and folders from archive to that folder
- In command line, using "cd", navigate to your Magento 2 root directory
- Run commands:

```
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy

```

How To Use
----------

[](#how-to-use)

```
protected $ipToCountryRepository;

public function __construct(
    \Magefan\GeoIp\Model\IpToCountryRepository $ipToCountryRepository,
    ....//other code
) {
    $this->ipToCountryRepository = $ipToCountryRepository;
    ...//other code
}

public function example() {
    $visitorCountyCode = $this->ipToCountryRepository->getVisitorCountryCode();
    $someCountryCodeByIp = $this->ipToCountryRepository->getCountryCode('104.27.164.57');
    ...//other code
}

```

Support
-------

[](#support)

If you have any issues, please [contact us](mailto:support@magefan.com)then if you still need help, open a bug report in GitHub's [issue tracker](https://github.com/magefan/module-geoip/issues).

Need More Features?
-------------------

[](#need-more-features)

Please contact us to get a quote

License
-------

[](#license)

The code is licensed under [Open Software License ("OSL") v. 3.0](http://opensource.org/licenses/osl-3.0.php) and [MaxMind EULA](https://www.maxmind.com/en/geolite2/eula).

This product includes GeoLite2 data created by MaxMind, available from [](https://www.maxmind.com).

Originally use these databases:
-------------------------------

[](#originally-use-these-databases)

[Magento Extensions](https://magefan.com/magento-2-extensions) by Magefan
-------------------------------------------------------------------------

[](#magento-extensions-by-magefan)

### Magento 2 SEO Extensions

[](#magento-2-seo-extensions)

- [Magento SEO](https://magefan.com/magento-2-seo-extension)
- [Magento 2 Rich Snippets](https://magefan.com/magento-2-rich-snippets)
- [Magento 2 HTML Sitemap](https://magefan.com/magento-2-html-sitemap-extension)
- [Magento 2 XML Sitemap](https://magefan.com/magento-2-xml-sitemap-extension)
- [Magento 2 Twitter Cards](https://magefan.com/magento-2-twitter-cards-extension)
- [Magento Open Graph Tags](https://magefan.com/magento-2-open-graph-extension-og-tags)

### [Magento 2 Google Extensions](https://magefan.com/magento-2-extensions/google-extensions)

[](#magento-2-google-extensions)

- [Magento Google Tag Manager](https://magefan.com/magento-2-google-tag-manager)
- [Magento 2 Google Analytics 4](https://magefan.com/magento-2-google-analytics-4)
- [Magento Google Shopping Feed](https://magefan.com/magento-2-google-shopping-feed-extension)
- [Magento Google Customer Reviews](https://magefan.com/magento-2-google-customer-reviews)
- [Magento 2 Google Indexing](https://magefan.com/magento-2-google-indexing-api)

### [Magento Speed Optimisation Extensions](https://magefan.com/magento-2-extensions/speed-optimization)

[](#magento-speed-optimisation-extensions)

- [Magento 2 Google Page Speed Optimizer](https://magefan.com/magento-2-google-page-speed-optimizer)
- [Magento 2 WebP Images](https://magefan.com/magento-2-webp-optimized-images)
- [Magento Full Page Cache Extension](https://magefan.com/magento-2-full-page-cache-warmer)
- [Magento 2 Lazy Load Images](https://magefan.com/magento-2-image-lazy-load-extension)
- [Magento 2 Defer JavaScript](https://magefan.com/rocket-javascript-deferred-javascript)

### [Magento Admin Extensions](https://magefan.com/magento-2-extensions/admin-extensions)

[](#magento-admin-extensions)

- [Magento 2 Dynamic Category](https://magefan.com/magento-2-dynamic-categories)
- [Magento 2 Size Chart](https://magefan.com/magento-2-size-chart)
- [Magento 2 Security Extension](https://magefan.com/magento-2-security-extension)
- [Magento 2 Admin Action Log](https://magefan.com/magento-2-admin-action-log)
- [Magento Extended Product Grid](https://magefan.com/magento-2-product-grid-inline-editor)
- [Magento 2 Product Tabs](https://magefan.com/magento-2/extensions/product-tabs)
- [Magento 2 Product Widget](https://magefan.com/magento-2-product-widget)
- [Magento 2 Email Attachments](https://magefan.com/magento-2-email-attachments)
- [Magento 2 Admin View](https://magefan.com/magento-2-admin-view-extension)
- [Magento 2 Email Notifications](https://magefan.com/magento-2-admin-email-notifications)
- [Magento 2 Login As Customer](https://magefan.com/login-as-customer-magento-2-extension)

### [Magento Order Management Extensions](https://magefan.com/magento-2-extensions/order-management)

[](#magento-order-management-extensions)

- [Magento Order Editor](https://magefan.com/magento-2-edit-order-extension)
- Better [Magento 2 Order Grid](https://magefan.com/magento-2-better-order-grid-extension)
- [Magento 2 Guest to Customer](https://magefan.com/magento2-convert-guest-to-customer)
- [Magento POS System](https://magefan.com/magento-pos-system)

### Magento 2 Blog Extensions

[](#magento-2-blog-extensions)

- [Magento 2 Blog Extension](https://magefan.com/magento2-blog-extension)
- [Magento 2 Multi Blog](https://magefan.com/magento-2-multi-blog-extension)

### [Magento Marketing Extensions](https://magefan.com/magento-2-extensions/marketing-automation)

[](#magento-marketing-extensions)

- [Magento 2 Facebook Pixel](https://magefan.com/magento-2-facebook-pixel-extension)
- [Magento TikTok Pixel](https://magefan.com/magento-2-tiktok-pixel)
- [Magento 2 Dynamic Blocks](https://magefan.com/magento-2-cms-display-rules-extension) and Pages
- [Magento 2 Cookie Consent](https://magefan.com/magento-2-cookie-consent)
- [Magento 2 Base Price](https://magefan.com/magento-2-base-price)
- [Magento 2 Price History](https://magefan.com/magento-2-price-history)
- [Magento 2 Mautic Extension](https://magefan.com/magento-2-mautic-extension)
- [Magento 2 YouTube Video](https://magefan.com/magento2-youtube-extension)

### [Magento Promotions Extensions](https://magefan.com/magento-2-extensions/promotions-extensions)

[](#magento-promotions-extensions)

- [Magento 2 Automatic Related Products](https://magefan.com/magento-2-automatic-related-products)
- [Magento 2 Product Labels](https://magefan.com/magento-2-product-labels)
- [Magento 2 Coupon Code Extension](https://magefan.com/magento-2-coupon-code-link)

### [Magento 2 Multi-Language Extensions](https://magefan.com/magento-2-extensions/multi-language-extensions)

[](#magento-2-multi-language-extensions)

- [Magento 2 Hreflang Tags](https://magefan.com/magento2-alternate-hreflang-extension)
- [Magento 2 Currency Switcher](https://magefan.com/magento-2-currency-switcher-auto-currency-by-country)
- [Magento 2 Language Switcher](https://magefan.com/magento-2-auto-language-switcher)
- [Magento 2 Store Switcher](https://magefan.com/magento-2-geoip-switcher-extension)
- [Magento 2 Translation Extension](https://magefan.com/magento-2-translation-extension)

### [Developers Tools](https://magefan.com/magento-2-extensions/developer-tools)

[](#developers-tools)

- [Magento Zero Downtime Deployment](https://magefan.com/blog/magento-2-zero-downtime-deployment)
- [Magento 2 Cron Schedule](https://magefan.com/magento-2-cron-schedule)
- [Magento 2 CLI Extension](https://magefan.com/magento2-cli-extension)
- [Magento 2 Conflict Detector](https://magefan.com/magento2-conflict-detector)

### [Shopify Apps](https://magefan.com/shopify/apps) by Magefan

[](#shopify-apps-by-magefan)

- [Shopify Login As Customer](https://apps.shopify.com/login-as-customer)
- [Shopify Blog](https://apps.shopify.com/magefan-blog)
- [Shopify Size Chart](https://magefan.com/shopify/apps/size-chart)
- [Shopify Google Indexer](https://magefan.com/shopify/apps/google-indexing)
- [Shopify Product Feeds](https://magefan.com/shopify/apps/product-feed)
- [Shopify Server GTM &amp; GA4](https://magefan.com/shopify/apps/gtm-and-ga4)

### [Magento 2 Services](https://magefan.com/services) by Magefan

[](#magento-2-services-by-magefan)

- [Magento Speed Optimization Service](https://magefan.com/magento-speed-optimization-service)
- [Magent SEO Service](https://magefan.com/magento-2-seo-service)
- [Custom Magento Development](https://magefan.com/custom-development)
- [Magento Installation Service](https://magefan.com/installation-service)

###  Health Score

59

—

FairBetter than 99% of packages

Maintenance74

Regular maintenance activity

Popularity49

Moderate usage in the ecosystem

Community21

Small or concentrated contributor base

Maturity74

Established project with proven stability

 Bus Factor1

Top contributor holds 82.8% 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 ~112 days

Recently: every ~123 days

Total

26

Last Release

231d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/48525307?v=4)[Ihor Vansach](/maintainers/IhorVansach)[@ihorvansach](https://github.com/ihorvansach)

---

Top Contributors

[![magefan](https://avatars.githubusercontent.com/u/9151916?v=4)](https://github.com/magefan "magefan (135 commits)")[![ihorvansach](https://avatars.githubusercontent.com/u/48525307?v=4)](https://github.com/ihorvansach "ihorvansach (15 commits)")[![KozakSerhii](https://avatars.githubusercontent.com/u/55527058?v=4)](https://github.com/KozakSerhii "KozakSerhii (5 commits)")[![andriysvyryda](https://avatars.githubusercontent.com/u/53607630?v=4)](https://github.com/andriysvyryda "andriysvyryda (3 commits)")[![termos008](https://avatars.githubusercontent.com/u/34942603?v=4)](https://github.com/termos008 "termos008 (2 commits)")[![DenysTsymbal](https://avatars.githubusercontent.com/u/61231452?v=4)](https://github.com/DenysTsymbal "DenysTsymbal (2 commits)")[![ivanhrytsaim](https://avatars.githubusercontent.com/u/155642341?v=4)](https://github.com/ivanhrytsaim "ivanhrytsaim (1 commits)")

---

Tags

magefanmagefan-extensionmagentomagento-2magento-2-extensionmagento-2-modulemagento-2extension-freemagento-extensionmagento-extension-freemagento-modulemagento-module-freemagento-pluginmagento2magento2-extensionmagento2-extension-freemagento2-free-extensionmagento2-modulemagento2-module-freemagento2-plugin

### Embed Badge

![Health badge](/badges/magefan-module-geoip/health.svg)

```
[![Health](https://phpackages.com/badges/magefan-module-geoip/health.svg)](https://phpackages.com/packages/magefan-module-geoip)
```

###  Alternatives

[stevebauman/location

Retrieve a user's location by their IP Address

1.3k7.6M65](/packages/stevebauman-location)[shlinkio/shlink

A self-hosted and PHP-based URL shortener application with CLI and REST interfaces

4.8k4.3k](/packages/shlinkio-shlink)[magefan/module-blog

Implements Blog functionality on Magento 2 store

2702.3M9](/packages/magefan-module-blog)[magefan/module-wysiwyg-advanced

Extend TinyMCE 4 in Magento 2

762.3M1](/packages/magefan-module-wysiwyg-advanced)[pulkitjalan/ip-geolocation

IP Geolocation Wrapper with Laravel Support

89164.9k1](/packages/pulkitjalan-ip-geolocation)[gpslab/geoip2

A Symfony Bundle for the Maxmind GeoIP2 API

541.5M3](/packages/gpslab-geoip2)

PHPackages © 2026

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