2017 © Pedro Peláez
 

library address-format

A PHP library to parse street addresses to localized formats

image

adamlc/address-format

A PHP library to parse street addresses to localized formats

  • Saturday, March 7, 2015
  • by adamlc
  • Repository
  • 4 Watchers
  • 64 Stars
  • 53,862 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 20 Forks
  • 0 Open issues
  • 12 Versions
  • 4 % Grown

The README.md

Address Format

Latest Version Software License GitHub Workflow Status Total Downloads, (*1)

A PHP library to parse street addresses to localized formats. The address formats are based on the formats supplied by Google's libaddressinput., (*2)

I have written a few basic unit tests, but they could probably be improved. Feel free to submit a pull request if you improve them!, (*3)

Composer

To install AddressFormat as a Composer package add this to your composer.json:, (*4)

"adamlc/address-format": "~1.3"

Run composer update, (*5)

Formatting a Street Address

//Create an address formatter instance
$address_formatter = new Adamlc\AddressFormat\Format;

//Set a locale using a two digit ISO country code.
$address_formatter->setLocale('GB');

//Set the address parts / attributes
$address_formatter['ADMIN_AREA'] = 'London';
$address_formatter['LOCALITY'] = 'Greenwich';
$address_formatter['RECIPIENT'] = 'Joe Bloggs';
$address_formatter['ORGANIZATION'] = 'Novotel London';
$address_formatter['POSTAL_CODE'] = 'SE10 8JA';
$address_formatter['STREET_ADDRESS'] = '173-185 Greenwich High Road';
$address_formatter['COUNTRY'] = 'United Kingdom';

//Get the address in localised format
$html = true; // Optional - return the address in HTML <br> instead of \n new lines

echo $address_formatter->formatAddress($html);

The above code will produce the following:, (*6)

Joe Bloggs
Novotel London
173-185 Greenwich High Road
Greenwich
London
SE10 8JA

Note: Look in the i18n directory to view the meta data for the locales., (*7)

The following attributes are available:, (*8)

ADMIN_AREA
LOCALITY
RECIPIENT
ORGANIZATION
DEPENDENT_LOCALITY
POSTAL_CODE
SORTING_CODE
STREET_ADDRESS
COUNTRY, (*9)

The Versions

07/03 2015

dev-master

9999999-dev https://github.com/adamlc/address-format

A PHP library to parse street addresses to localized formats

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

07/03 2015

1.3.3

1.3.3.0 https://github.com/adamlc/address-format

A PHP library to parse street addresses to localized formats

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

27/01 2015

1.3.2

1.3.2.0 https://github.com/adamlc/address-format

A PHP library to parse street addresses to localized formats

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

12/01 2015

1.3.1

1.3.1.0 https://github.com/adamlc/address-format

A PHP library to parse street addresses to localized formats

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

09/12 2014

1.3

1.3.0.0 https://github.com/adamlc/address-format

A PHP library to parse street addresses to localized formats

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

07/12 2014

v1.2

1.2.0.0 https://github.com/adamlc/address-format

A PHP library to parse street addresses to localized formats

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

07/12 2014

1.2

1.2.0.0 https://github.com/adamlc/address-format

A PHP library to parse street addresses to localized formats

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

09/10 2014

1.1.0

1.1.0.0 https://github.com/adamlc/address-format

A PHP library to parse street addresses to localized formats

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

16/04 2014

1.0.3

1.0.3.0 https://github.com/adamlc/address-format

A PHP library to parse street addresses to localized formats

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

24/03 2014

1.0.2

1.0.2.0 https://github.com/adamlc/address-format

A PHP library to parse street addresses to localized formats

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

27/01 2014

1.0.1

1.0.1.0 https://github.com/adamlc/address-format

A PHP library to parse street addresses to localized formats

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

16/08 2013

v1.0.0

1.0.0.0 https://github.com/adamlc/address-format

A PHP library to parse street addresses to localized formats

  Sources   Download

MIT

The Requires

  • php >=5.3.0