Download the PHP package sparefoot/geocoder without Composer

On this page you can find all versions of the php package sparefoot/geocoder. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package geocoder

Geocoder

Build
Status Total
Downloads Latest Stable
Version PHP7 ready

Important: You are browsing the documentation of Geocoder 4.x (not released yet).

Documentation for version 3.x is available here: Geocoder 3.x documentation.

Documentation for version 2.x is available here: Geocoder 2.x documentation.


Geocoder is a PHP library which helps you build geo-aware applications by providing a powerful abstraction layer for geocoding manipulations.

Installation

The recommended way to install Geocoder is through Composer:

Usage

Geocoder and its companion Geocoder Extra provides a lot of providers.

Choose the one that fits your need first. Let's say the GoogleMaps one is what you were looking for, so let's see how to use it. In the code snippet below, curl has been chosen as HTTP layer but it is up to you since each HTTP-based provider implements PSR-7.

The Provider interface has three methods:

The Geocoder interface extends the Provider interface and exposes two additional methods. They will make migration from 3.x smoother.

Address & AddressCollection

Both geocode() and reverse() methods return a collection of Address objects (AddressCollection), each providing the following API:

The AddressCollection exposes the following methods:

The ProviderAggregator

The ProviderAggregator is used to register several providers so that you can decide which provider to use later on.

The ProviderAggregator's API is fluent, meaning you can write:

The using() method allows you to choose the provider to use by its name. When you deal with multiple providers, you may want to choose one of them. The default behavior is to use the first one but it can be annoying.

The limit() method allows you to configure the maximum number of results being returned. Depending on the provider you may not get as many results as expected, it is a maximum limit, not the expected number of results.

TimedGeocoder

The TimedGeocoder class profiles each geocode and reverse call. So you can easily figure out how many time/memory was spent for each geocoder/reverse call.

We use the symfony/stopwatch component under the hood. Which means, if you use the Symfony framework the geocoder calls will appear in your timeline section in the Web Profiler.

HTTP Adapters

In order to talk to geocoding APIs, you need HTTP adapters. While it was part of the library in Geocoder 1.x and 2.x, Geocoder 3.x and upper now relies on the PSR-7 Standard which defines how HTTP message should be implemented. You can use any library to send HTTP messages that implements php-http/client-implementation.

To use Guzzle 6 you should run the following command:

Providers

Providers perform the geocoding black magic for you (talking to the APIs, fetching results, dealing with errors, etc.) and are highly configurable.

Address-based Providers

Provider Name Reverse? SSL? Coverage Multiple? Terms
ArcGIS Online arcgis_online yes supported worldwide yes requires API key. 1250 requests free
Bing Maps bing_maps yes no worldwide yes requires API key. Limit 10,000 requests per month
Chain chain meta provider which iterates over a list of providers
Geonames geonames yes no worldwide yes requires registration, no free tier
Google Maps google_maps yes supported worldwide yes requires API key. Limit 2500 requests per day
Google Maps for Business google_maps_business yes supported worldwide yes requires API key. Limit 100,000 requests per day
MapQuest map_quest yes no worldwide yes both open and commercial service requires API key
Mapzen mapzen yes supported worldwide yes requires API key; limited to 6 request/sec, 30,000 request/day
Nominatim nominatim yes supported worldwide yes requires a domain name (e.g. local installation)
OpenCage opencage yes supported worldwide yes requires API key. 2500 requests/day free
OpenStreetMap openstreetmap yes no worldwide yes heavy users (>1q/s) get banned
TomTom tomtom yes required worldwide yes requires API key. First 2500 requests or 30 days free
Yandex yandex yes no worldwide yes

Below, you will find more information for these providers.

ArcGISOnline

It is possible to specify a sourceCountry to restrict result to this specific country thus reducing request time (note that this doesn't work on reverse geocoding).

GeoIP2

It requires either the database file, or the webservice - represented by the GeoIP2 , which is injected to the GeoIP2Adapter. The geoip2/geoip2 package must be installed.

This provider will only work with the corresponding GeoIP2Adapter:

GoogleMaps

Locale and/or region can be specified:

GoogleMapsBusiness

A valid Client ID is required. The private key is optional. This provider also supports SSL, and extends the GoogleMaps provider.

Mapzen

A valid API key is required. This provider also supports SSL.

MaxMindBinary

This provider requires a data file, and the geoip/geoip package must be installed.

It is worth mentioning that this provider has serious performance issues, and should not be used in production. For more information, please read issue #301.

Nominatim

Access to a Nominatim server is required. See the Nominatim Wiki Page for more information.

TomTom

The default language-locale is en, you can choose between de, es, fr, it, nl, pl, pt and sv.

Yandex

The default language-locale is ru-RU, you can choose between uk-UA, be-BY, en-US, en-BR and tr-TR. This provider can also reverse information based on coordinates (latitude, longitude). It's possible to precise the toponym to get more accurate result for reverse geocoding: house, street, metro, district and locality.

IP-based Providers

Provider Name IPv4? IPv6? Multiple? Terms Notes
FreeGeoIp free_geo_ip yes yes no
GeoIPs geo_ips yes no no requires API key
GeoIP2 (Maxmind) maxmind_geoip2 yes yes no
GeoPlugin geo_plugin yes yes no
HostIp host_ip yes no no
IpInfoDB ip_info_db yes no no requires API key city precision
Geoip geoip yes no no wrapper around the PHP extension which must be installed
MaxMind web service maxmind yes yes no requires Omni API key City/ISP/Org and Omni services, IPv6 on country level
MaxMind Binary file maxmind_binary yes no no needs locally installed database files

Important: the Geocoder Extra library contains even more official providers!

Locale Aware Providers

Providers that are locale aware expose the following methods:

The Chain Provider

The Chain provider is a special provider that takes a list of providers and iterates over this list to get information. Note that it stops its iteration when a provider returns a result. The result is returned by GoogleMaps because FreeGeoIp and HostIp cannot geocode street addresses. BingMaps is ignored.

Everything is ok, enjoy!

Dumpers

Geocoder provides dumpers that aim to transform an Address object in standard formats.

GPS eXchange Format (GPX)

The GPS eXchange format is designed to share geolocated data like point of interests, tracks, ways, but also coordinates. Geocoder provides a dumper to convert an Address object in an GPX compliant format.

Assuming we got a $address object as seen previously:

It will display:

GeoJSON

GeoJSON is a format for encoding a variety of geographic data structures.

GeoArray

Simple PHP array format for using with your own encoders.

Keyhole Markup Language (KML)

Keyhole Markup Language is an XML notation for expressing geographic annotation and visualization within Internet-based, two-dimensional maps and three-dimensional Earth browsers.

Well-Known Binary (WKB)

The Well-Known Binary (WKB) representation for geometric values is defined by the OpenGIS specification.

Well-Known Text (WKT)

Well-known text (WKT) is a text markup language for representing vector geometry objects on a map, spatial reference systems of spatial objects and transformations between spatial reference systems.

Formatters

A common use case is to print geocoded data. Thanks to the StringFormatter class, it's simple to format an Address object as a string:

Here is the mapping:

Extending Things

You can write your own provider by implementing the Provider interface.

You can provide your own dumper by implementing the Dumper interface.

Versioning

Geocoder follows Semantic Versioning.

End Of Life

1.x

As of December 2014, branch 1.7 is not officially supported anymore, meaning major version 1 reached end of life. Last version is: 1.7.1.

2.x

As of December 2014, version 2.x is in a feature frozen state. All new features should be contributed to version 3.0 and upper. Last version is: 2.8.1.

Major version 2 will reach end of life on December 2015.

Stable Version

Version 3.x is the current major stable version of Geocoder.

Cookbook

We have a small cookbook where you can find examples on common use cases:

Contributing

See CONTRIBUTING file.

Unit Tests

In order to run the test suite, install the development dependencies:

Then, run the following command:

You'll obtain some skipped unit tests due to the need of API keys.

Rename the phpunit.xml.dist file to phpunit.xml, then uncomment the following lines and add your own API keys:

You're done.

Credits

Contributor Code of Conduct

As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.

We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.

Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.

Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.

This Code of Conduct is adapted from the Contributor Covenant, version 1.0.0, available at http://contributor-covenant.org/version/1/0/0/

License

Geocoder is released under the MIT License. See the bundled LICENSE file for details.


All versions of geocoder with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
egeloen/http-adapter Version ~0.8
igorw/get-in Version ~1.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package sparefoot/geocoder contains the following files

Loading the files please wait ....