PHPackages                             geocoder-php/stack-geo-ip - 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. geocoder-php/stack-geo-ip

ActiveLibrary

geocoder-php/stack-geo-ip
=========================

Geolocation Stack middleware for Geocoder library.

1.0.3(11y ago)404258[1 issues](https://github.com/geocoder-php/StackGeoIp/issues)MITPHPPHP &gt;=5.4.0

Since Sep 11Pushed 11y ago5 watchersCompare

[ Source](https://github.com/geocoder-php/StackGeoIp)[ Packagist](https://packagist.org/packages/geocoder-php/stack-geo-ip)[ RSS](/packages/geocoder-php-stack-geo-ip/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (4)Dependencies (7)Versions (6)Used By (0)

StackGeoIp
==========

[](#stackgeoip)

Geolocation [Stack](http://stackphp.com/) middleware that adds geolocation results to the request for subsequent middlewares by leveraging the [Geocoder](http://geocoder-php.org/) library.

[![Build Status](https://camo.githubusercontent.com/042df4e49efbcbfd089411e32f2cbb1162b94c1cb59fa89e56bb392a96b47c9f/68747470733a2f2f7472617669732d63692e6f72672f67656f636f6465722d7068702f537461636b47656f49702e706e67)](https://travis-ci.org/geocoder-php/StackGeoIp)

Usage
-----

[](#usage)

### Example

[](#example)

Here we create a simple application that returns the IP address of the request and the contents of the `X-Country` header to the browser. Normally, the `X-Country` header would not exists.

By wrapping the GeoIP middleware around it using the StackBuilder, if the IP address can be matched to a country, the `X-Country` header will be set to the two-letter code for that country, and be available to the application.

```
