Download the PHP package socloz/geocoder without Composer

On this page you can find all versions of the php package socloz/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

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

Build Status

HttpAdapters

HttpAdapters are responsible to get data from remote APIs.

Currently, there are the following adapters:

Providers

Providers contain the logic to extract useful information.

Currently, there are many providers for the following APIs:

Installation

The recommended way to install Geocoder is through composer.

Just create a composer.json file for your project:

And run these two commands to install it:

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

If you don't use neither Composer nor a ClassLoader in your application, just require the provided autoloader:

You're done.

Usage

First, you need an adapter to query an API:

The BuzzHttpAdapter is tweakable, actually you can pass a Browser object to this adapter:

Now, you have to choose a provider which is closed to what you want to get.

FreeGeoIpProvider

The FreeGeoIpProvider is able to geocode IPv4 and IPv6 addresses only.

HostIpProvider

The HostIpProvider is able to geocode IPv4 addresses only.

IpInfoDbProvider

The IpInfoDbProvider is able to geocode IPv4 addresses only. A valid api key is required.

YahooProvider

The YahooProvider is able to geocode both IPv4 addresses and street addresses. This provider can also reverse information based on coordinates (latitude, longitude). A valid api key is required.

GoogleMapsProvider

The GoogleMapsProvider is able to geocode and reverse geocode street addresses.

BingMapsProvider

The BingMapsProvider is able to geocode and reverse geocode street addresses. A valid api key is required.

OpenStreetMapsProvider

The OpenStreetMapsProvider is able to geocode and reverse geocode street addresses.

CloudMadeProvider

The CloudMadeProvider is able to geocode and reverse geocode street addresses. A valid api key is required.

GeoipProvider

The GeoipProvider is able to geocode IPv4 and IPv6 addresses only. No need to use an HttpAdapter as it uses a local database. See the MaxMind page for more information.

ChainProvider

The ChainProvider is a special provider that takes a list of providers and iterates over this list to get information.

MapQuestProvider

The MapQuestProvider is able to geocode and reverse geocode street addresses.

OIORestProvider

The OIORestProvider is able to geocode and reverse geocode street addresses, exclusively in Denmark.

GeocoderCaProvider

The GeocoderCaProvider is able to geocode and reverse geocode street addresses, exclusively in USA & Canada.

GeocoderUsProvider

The GeocoderUsProvider is able to geocode street addresses only, exclusively in USA.

IGNOpenLSProvider

The IGNOpenLSProvider is able to geocode street addresses only, exclusively in France. A valid api key is required.

DataScienceToolkitProvider

The DataScienceToolkitProvider is able to geocode IPv4 addresses only.

YandexProvider

The YandexProvider is able to geocode and reverse geocode street addresses. The default langage-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: house, street, metro, district and locality.

GeoPluginProvider

The GeoPluginProvider is able to geocode IPv4 addresses and IPv6 addresses only.

GeoIPsProvider

The GeoIPsProvider is able to geocode IPv4 addresses only. A valid api key is required.

MaxMindProvider

The MaxMindProvider is able to geocode IPv4 addresses only. A valid api key is required.

You can use one of them or write your own provider. You can also register all providers and decide later. That's we'll do:

The $locale parameter is available for the YahooProvider.

Everything is ok, enjoy!

API

The main method is called geocode() which receives a value to geocode. It can be an IP address or a street address (partial or not).

The geocode() method returns a Geocoded result object with the following API, this object also implements the ArrayAccess interface:

The Geocoder's API is fluent, you can write:

The using() method allows you to choose the provider to use. 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.

Reverse Geocoding

This library provides a reverse() method to retrieve information from coordinates:

Dumpers

Geocoder provides dumpers that aim to transform a ResultInterface 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 a ResultInterface object in an GPX compliant format.

Assuming we got a $result object as seen previously:

It will display:

GeoJSON

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

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.

Formatter

A common use case is to print geocoded data. Thanks to the Formatter class, it's really easy to format a ResultInterface object as a string:

Here is the mapping:

Extending Things

You can provide your own adapter, you just need to create a new class which implements HttpAdapterInterface.

You can also write your own provider by implementing the ProviderInterface.

Note, the AbstractProvider class can help you by providing useful features.

You can provide your own dumper by implementing the DumperInterface.

Write your own formatter by implementing the FormatterInterface.

Unit Tests

To run unit tests, you'll need cURL and a set of dependencies you can install using Composer:

Once installed, just launch 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

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.3.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 socloz/geocoder contains the following files

Loading the files please wait ....