PHPackages                             antwebes/geocoder - 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. antwebes/geocoder

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

antwebes/geocoder
=================

The almost missing Geocoder PHP 5.3 library.

2.4.2(12y ago)13.0k1MITPHPPHP &gt;=5.3.0

Since Jan 2Pushed 12y ago3 watchersCompare

[ Source](https://github.com/antwebes/Geocoder)[ Packagist](https://packagist.org/packages/antwebes/geocoder)[ Docs](http://geocoder-php.org)[ RSS](/packages/antwebes-geocoder/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (4)Versions (43)Used By (0)

Geocoder
========

[](#geocoder)

**Geocoder** is a library which helps you build geo-aware applications. It provides an abstraction layer for geocoding manipulations. The library is split in two parts: `HttpAdapter` and `Provider` and is really extensible.

[![Build Status](https://camo.githubusercontent.com/1971e06f55456caecadf5fb297aa7f7ac695ae7eca77bb3f4fb4899feb1dcb93/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f67656f636f6465722d7068702f47656f636f6465722e706e67)](http://travis-ci.org/geocoder-php/Geocoder)

### HttpAdapters

[](#httpadapters)

*HttpAdapters* are responsible to get data from remote APIs.

Currently, there are the following adapters:

- `BuzzHttpAdapter` to use [Buzz](https://github.com/kriswallsmith/Buzz), a lightweight PHP 5.3 library for issuing HTTP requests;
- `CurlHttpAdapter` to use [cURL](http://php.net/manual/book.curl.php);
- `GuzzleHttpAdapter` to use [Guzzle](https://github.com/guzzle/guzzle), PHP 5.3+ HTTP client and framework for building RESTful web service clients;
- `SocketHttpAdapter` to use a [socket](http://www.php.net/manual/function.fsockopen.php);
- `ZendHttpAdapter` to use [Zend Http Client](http://framework.zend.com/manual/2.0/en/modules/zend.http.client.html).

### Providers

[](#providers)

*Providers* contain the logic to extract useful information.

Currently, there are many providers for the following APIs:

- [FreeGeoIp](http://freegeoip.net/static/index.html) as IP-Based geocoding provider;
- [HostIp](http://www.hostip.info/) as IP-Based geocoding provider;
- [IpInfoDB](http://www.ipinfodb.com/) as IP-Based geocoding provider (city precision);
- [Google Maps](http://code.google.com/apis/maps/documentation/geocoding/) as Address-Based geocoding and reverse geocoding provider;
- [Google Maps for Business](https://developers.google.com/maps/documentation/business/webservices) as Address-Based geocoding and reverse geocoding provider;
- [Bing Maps](http://msdn.microsoft.com/en-us/library/ff701715.aspx) as Address-Based geocoding and reverse geocoding provider;
- [OpenStreetMap](http://nominatim.openstreetmap.org/) as Address-Based geocoding and reverse geocoding provider (based on the Nominatim provider);
- [Nominatim](http://wiki.openstreetmap.org/wiki/Nominatim) as Address-Based geocoding and reverse geocoding provider;
- [CloudMade](http://developers.cloudmade.com/projects/show/geocoding-http-api) as Address-Based geocoding and reverse geocoding provider;
- [Geoip](http://php.net/manual/book.geoip.php), the PHP extension, as IP-Based geocoding provider;
- ChainProvider is a special provider that takes a list of providers and iterates over this list to get information;
- [MapQuest](http://open.mapquestapi.com/) as Address-Based geocoding and reverse geocoding provider;
- [OIORest](http://geo.oiorest.dk/) as very accurate Address-Based geocoding and reverse geocoding provider (exclusively in Denmark);
- [GeoCoder.ca](http://geocoder.ca/) as Address-Based geocoding and reverse geocoding provider (exclusively in USA &amp; Canada);
- [GeoCoder.us](http://geocoder.us/) as Address-Based geocoding provider (exclusively in USA);
- [IGN OpenLS](http://www.ign.fr/) as Address-Based geocoding provider (exclusively in France);
- [DataScienceToolkit](http://www.datasciencetoolkit.org/) as IP-Based geocoding provider or an Address-Based provider (exclusively in USA &amp; Canada);
- [Yandex](http://api.yandex.com.tr/maps/doc/geocoder/desc/concepts/About.xml) as Address-Based geocoding and reverse geocoding provider;
- [GeoPlugin](http://www.geoplugin.com/webservices) as IP-Based geocoding provider;
- [GeoIPs](http://www.geoips.com/developer/geoips-api) as IP-Based geocoding provider;
- [MaxMind web service](http://dev.maxmind.com/geoip/legacy/web-services) as IP-Based geocoding provider (City/ISP/Org and Omni services);
- [MaxMind binary file](http://dev.maxmind.com/geoip/legacy/downloadable) as IP-Based geocoding provider;
- [Geonames](http://www.geonames.org/) as Place-Based geocoding and reverse geocoding provider;
- [IpGeoBase](http://ipgeobase.ru/) as IP-Based geocoding provider (very accurate in Russia);
- [Baidu](http://developer.baidu.com/map/geocoding-api.htm) as Address-Based geocoding and reverse geocoding provider (exclusively in China);
- [TomTom](http://developer.tomtom.com/docs/read/Geocoding) as Address-Based geocoding and reverse geocoding provider;
- [ArcGIS Online](http://resources.arcgis.com/en/help/arcgis-online-geocoding-rest-api/) as Address-Based geocoding and reverse geocoding provider.

The [Geocoder Extra](https://github.com/geocoder-php/geocoder-extra) library contains even more providers!

Installation
------------

[](#installation)

The recommended way to install Geocoder is through composer.

Just create a `composer.json` file for your project:

```
{
    "require": {
        "willdurand/geocoder": "@stable"
    }
}
```

**Protip:** you should browse the [`willdurand/geocoder`](https://packagist.org/packages/willdurand/geocoder)page to choose a stable version to use, avoid the `@stable` meta constraint.

And run these two commands to install it:

```
$ curl -sS https://getcomposer.org/installer | php
$ composer install
```

Now you can add the autoloader, and you will have access to the library:

```
