Download the PHP package predicthq/address-formatter-templates without Composer

On this page you can find all versions of the php package predicthq/address-formatter-templates. 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 address-formatter-templates

Build Status

address formatting

A quick example

Given a set of address parts

 house_number:  17
 road:          Rue du Médecin-Colonel Calbairac
 neighbourhood: Lafourguette
 suburb:        Toulouse Ouest
 postcode:      31000
 city:          Toulouse
 county:        Toulouse
 state:         Midi-Pyrénées
 country:       France
 country_code:  FR

you want to write logic to compile addresses in the format consumers expect

17 Rue du Médecin-Colonel Calbairac
31000 Toulouse
France

or perhaps simply

Rue du Médecin-Colonel Calbairac
Toulouse
France

This repository contains templates for various address formats used in territories around the world. It also contains test cases.

Which addresses we're talking about

The intended use-case is database or geocoding systems (forward, reverse, autocomplete) where we know both the country of the address and the language of the user/reader. The address is displayed to a consumer (for example in an app) and not used to print on an envelope for actual postal delivery. We use it to format output from the OpenCage Geocoder.

We have to deal with

Unlike physical post (office) mail we don't have to deal with

Processing logic

Our goal with this repository is a series of (programming) language independent templates. Those templates can then be processed by whatever software you like.

We've written, use and maintain a working implementation of a processer in Perl, see (CPAN: Geo::Address::Formatter, github repo). There is also an open-source implementation in PHP.

We would love there to be other langauge implementations. If you do write a processor, please let us know so we can list it here.

Coverage

As of Sat 25 Mar 2017 coverage is:

We are aware of 248 territories
We have tests for 250 (100%) territories
We have rules for 249 (100%) territories
0 (0%) territories have neither rules nor tests

We need more language specific abbreviations, please see conf/abbreviations

A detailed breakdown of test and configuration coverage can be found by running bin/coverage.pl -d. A list of all known territories is in conf/country_codes.yaml Note: the list is simple all officially assigned ISO 3166-1 alpha-2 codes, and is not a political statement on whether or not these territories are or are not or should or should not be political states.

File format

The files are in YAML format. The templates are written in Mustache. Both formats are human readable, strict, solve escaping and support comments. YAML allows references (called "ankers") to avoid copy&paste, Mustache allows sub-templates (called "partials").

How to add your country/territory

  1. edit the .yaml testcase for the country/territory in testcases/countries. The file names correspond to the appropriate ISO 3166-1 alpha-2 code - see conf/country_codes.yaml

    • a good way to get sample data is:
      • find an addressed location (house, business, etc) in your target territory in OpenStreetMap
      • get the coordinates (lat, long) of the location
      • put the coordinates into the OpenCage Geocoder demo page
      • look at the resulting JSON in the Raw Response tab
  2. edit conf/countries/worldwide.yaml

    • Possibly your country/territory uses an existing generic format as defined at the top of the file. If so, great, just map you country_code to the generic template. You may still want to add clean up code (see the entry for DE as an example).
    • If not you need to define a new generic rule set
      • possibly you will need to define new state/region mappings in conf/state_codes.yaml
  3. to test you will now need to process the .yaml test via a processer (see above) and ensure the input leads to the desired output.

If in doubt, please get in touch via github issues.

Formatting rules

Currently we support the following formatting rules:

The future

More tests! For every rule about addresses there are exceptions and edge cases to consider. More test cases are always needed.

Planned features

We welcome your pull requests. Together we can address the world!

Who are we?

We run the OpenCage Geocoder.

We also run #geomob, a meetup of London location based service developers where we do our best to highlight geoinnovation.

Further reading

Here's our blog post anouncing this project and the motivations behind it.

You may enjoy Michael Tandy's Falsehoods Programmers Believe about Addresses.

If it's actual address data you're after, check out OpenAddresses.

If you want to turn longitude, latitude into well formatted addresses or placenames, well that's what a geocoder does. Check out ours: OpenCage Geocoder.

If all this convinces you that address are evil, please check out what3words which allows you to dispense with them entirely.


All versions of address-formatter-templates with dependencies

PHP Build Version
Package Version
No informations.
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 predicthq/address-formatter-templates contains the following files

Loading the files please wait ....