PHPackages                             survos/ip2location-bundle - 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. survos/ip2location-bundle

ActiveSymfony-bundle[Utility &amp; Helpers](/categories/utility)

survos/ip2location-bundle
=========================

Symfony wrapper for ip2location.ip

2.0.83(6mo ago)0561MITPHPPHP ^8.4

Since Feb 19Pushed 5mo ago2 watchersCompare

[ Source](https://github.com/survos/Ip2LocationBundle)[ Packagist](https://packagist.org/packages/survos/ip2location-bundle)[ GitHub Sponsors](https://github.com/kbond)[ RSS](/packages/survos-ip2location-bundle/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (13)Versions (491)Used By (0)

Ip2Location Bundle
==================

[](#ip2location-bundle)

Symfony Bundle for the [ip2location/ip2location-io-php](https://github.com/ip2location/ip2location-io-php) library, to get data from an IP address.

First, get an API key at  and add it to .env.local

```
echo "IP2LOCATION_API_KEY=my-api-key" >> .env.local
composer req survos/ip2location-bundle
bin/console debug:config survos_ip2_location --format=yaml > config/packages/survos_ip2_location.yaml
```

```
{{ ipGeolocation(app.request.clientIp).country_code}}
```

By default, the bundle gets the API key from the environment. Since localhost doesn't have geolocation data, you can set a default. If you're running locally, the remote address is localhost. Get your real IP address at whatismyip.com or

```
# config/packages/survos_ip2location.yaml
survos_ip2_location:
  api_key: '%env(IP2LOCATION_API_KEY)%'
  localhost_ip: 8.8.8.8

```

Trivial but functional application
----------------------------------

[](#trivial-but-functional-application)

Requirements:

- Locally installed PHP 8
- Symfony CLI
- sed (to change /app to / without opening an editor)
- API Key

```
symfony new Ip2locationDemo --webapp && cd Ip2locationDemo
echo "IP2LOCATION_API_KEY=my-api-key" >> .env.local
symfony composer req survos/ip2location-bundle
symfony console make:controller AppController
sed -i "s|/app|/|" src/Controller/AppController.php

cat  templates/app/index.html.twig
{% extends 'base.html.twig' %}
{% block body %}
{% set ip = app.request.clientIp %}
{{ isLocalhost(ip) ? "Localhost has no geolocation, using value from config" }}
Hello, visitor from {{ ipGeolocation(ip).country_name}} )
{{ ipGeolocation(ip)|json_encode(constant('JSON_PRETTY_PRINT')) }}

Powered by IP2Location.io IP geolocation web service.

{% endblock %}
EOF

symfony server:start -d
symfony open:local
```

###  Health Score

45

—

FairBetter than 92% of packages

Maintenance70

Regular maintenance activity

Popularity13

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity78

Established project with proven stability

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 ~1 days

Total

490

Last Release

201d ago

Major Versions

1.6.12 → 2.0.192025-09-28

PHP version history (3 changes)1.5.150PHP ^8.1

1.5.459PHP ^8.3

2.0.19PHP ^8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/21b39551f92ed4143772c622f9e571589c5a72c96ab3c53fe67489ce0d83e806?d=identicon)[tacman1123](/maintainers/tacman1123)

---

Tags

geolocationIPsymfony6

###  Code Quality

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/survos-ip2location-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/survos-ip2location-bundle/health.svg)](https://phpackages.com/packages/survos-ip2location-bundle)
```

###  Alternatives

[codefog/contao-haste

haste extension for Contao Open Source CMS

42650.8k139](/packages/codefog-contao-haste)[spomky-labs/pwa-bundle

Progressive Web App Manifest Generator Bundle for Symfony.

6144.4k1](/packages/spomky-labs-pwa-bundle)[netgen/layouts-core

Netgen Layouts enables you to build and manage complex web pages in a simpler way and with less coding. This is the core of Netgen Layouts, its heart and soul.

3689.4k10](/packages/netgen-layouts-core)[netgen/content-browser

Netgen Content Browser is a Symfony bundle that provides an interface which selects items from any kind of backend and returns the IDs of selected items back to the calling code.

14112.1k8](/packages/netgen-content-browser)

PHPackages © 2026

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