PHPackages                             adamlc/address-format - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. adamlc/address-format

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

adamlc/address-format
=====================

A PHP library to parse street addresses to localized formats

2.0.2(1y ago)84196.4k↑27.8%212MITPHPPHP &gt;=5.3.0

Since Aug 16Pushed 1y ago3 watchersCompare

[ Source](https://github.com/adamlc/address-format)[ Packagist](https://packagist.org/packages/adamlc/address-format)[ Docs](https://github.com/adamlc/address-format)[ RSS](/packages/adamlc-address-format/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (1)Versions (16)Used By (2)

Address Format
==============

[](#address-format)

[![Latest Version](https://camo.githubusercontent.com/1cbd535ebf7fbb045fd67c07510ed6c7b39efc8e21f67171cf06006e509dec1e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f7461672f6164616d6c632f616464726573732d666f726d61742e7376673f6c6162656c3d72656c65617365267374796c653d666c61742d737175617265)](https://github.com/adamlc/address-format/releases)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![GitHub Workflow Status](https://camo.githubusercontent.com/afc44f5b81163385a9708cd437c7b6b2388b8d5df890117b2367b75f978c5b63/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6164616d6c632f616464726573732d666f726d61742f63692e796d6c3f7374796c653d666c61742d737175617265)](https://github.com/adamlc/address-format/actions/workflows/ci.yml)[![Total Downloads](https://camo.githubusercontent.com/2b7684d1b100d947dbff0a58224908cb6f24cc628b353aaf36a7788e00515aed/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6164616d6c632f616464726573732d666f726d61742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/adamlc/address-format)

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

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!

Composer
--------

[](#composer)

To install AddressFormat as a Composer package add this to your composer.json:

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

Run `composer update`

Formatting a Street Address
---------------------------

[](#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  instead of \n new lines

echo $address_formatter->formatAddress($html);
```

The above code will produce the following:

```
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.

The following attributes are available:

ADMIN\_AREA
LOCALITY
RECIPIENT
ORGANIZATION
DEPENDENT\_LOCALITY
POSTAL\_CODE
SORTING\_CODE
STREET\_ADDRESS
COUNTRY

###  Health Score

49

—

FairBetter than 95% of packages

Maintenance42

Moderate activity, may be stable

Popularity49

Moderate usage in the ecosystem

Community25

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 58% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~299 days

Recently: every ~199 days

Total

15

Last Release

469d ago

Major Versions

1.5.0 → 2.0.02025-01-14

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/809944?v=4)[Adam Curtis](/maintainers/adamlc)[@adamlc](https://github.com/adamlc)

---

Top Contributors

[![adamlc](https://avatars.githubusercontent.com/u/809944?v=4)](https://github.com/adamlc "adamlc (40 commits)")[![JapSeyz](https://avatars.githubusercontent.com/u/2234034?v=4)](https://github.com/JapSeyz "JapSeyz (8 commits)")[![jmslbam](https://avatars.githubusercontent.com/u/145887?v=4)](https://github.com/jmslbam "jmslbam (7 commits)")[![crishoj](https://avatars.githubusercontent.com/u/20393?v=4)](https://github.com/crishoj "crishoj (5 commits)")[![travisulrich](https://avatars.githubusercontent.com/u/6855038?v=4)](https://github.com/travisulrich "travisulrich (3 commits)")[![luigifab](https://avatars.githubusercontent.com/u/31816829?v=4)](https://github.com/luigifab "luigifab (2 commits)")[![ickbinhier](https://avatars.githubusercontent.com/u/2810904?v=4)](https://github.com/ickbinhier "ickbinhier (1 commits)")[![mikemand](https://avatars.githubusercontent.com/u/745184?v=4)](https://github.com/mikemand "mikemand (1 commits)")[![Nyholm](https://avatars.githubusercontent.com/u/1275206?v=4)](https://github.com/Nyholm "Nyholm (1 commits)")[![chandon](https://avatars.githubusercontent.com/u/4522557?v=4)](https://github.com/chandon "chandon (1 commits)")

---

Tags

composerformatterphpphp-librarystreet-address

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/adamlc-address-format/health.svg)

```
[![Health](https://phpackages.com/badges/adamlc-address-format/health.svg)](https://phpackages.com/packages/adamlc-address-format)
```

###  Alternatives

[masterminds/html5

An HTML5 parser and serializer.

1.8k242.8M229](/packages/masterminds-html5)[sabberworm/php-css-parser

Parser for CSS Files written in PHP

1.8k191.2M65](/packages/sabberworm-php-css-parser)[jms/metadata

Class/method/property metadata management in PHP

1.8k152.8M88](/packages/jms-metadata)[jms/serializer-bundle

Allows you to easily serialize, and deserialize data of any complexity

1.8k89.3M627](/packages/jms-serializer-bundle)[hassankhan/config

Lightweight configuration file loader that supports PHP, INI, XML, JSON, and YAML files

97513.5M170](/packages/hassankhan-config)[meyfa/php-svg

Read, edit, write, and render SVG files with PHP

54613.9M42](/packages/meyfa-php-svg)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
