PHPackages                             predicthq/address-formatter - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. predicthq/address-formatter

AbandonedArchivedLibrary[Utility &amp; Helpers](/categories/utility)

predicthq/address-formatter
===========================

Address formatter using country templates from https://github.com/OpenCageData/address-formatting

v1.1.0(8y ago)35185.7k↓38.1%21[4 PRs](https://github.com/predicthq/address-formatter-php/pulls)MITPHPPHP &gt;=5.6.0

Since Apr 26Pushed 6y ago3 watchersCompare

[ Source](https://github.com/predicthq/address-formatter-php)[ Packagist](https://packagist.org/packages/predicthq/address-formatter)[ RSS](/packages/predicthq-address-formatter/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (7)Dependencies (5)Versions (8)Used By (0)

Address Formatter for PHP
=========================

[](#address-formatter-for-php)

[![Build Status](https://camo.githubusercontent.com/d5facb94232147d149ccddc3e72293204c08b716be710fa141beda1a7922bad0/68747470733a2f2f7472617669732d63692e6f72672f7072656469637468712f616464726573732d666f726d61747465722d7068702e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/predicthq/address-formatter-php)[![Coverage Status](https://camo.githubusercontent.com/2baa9eeef375acf91fc6c7eb0e3b662c938471dc581c577d838b9e71d85ea2ab/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f7072656469637468712f616464726573732d666f726d61747465722d7068702f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/predicthq/address-formatter-php?branch=master)

This library uses the address templates from  to format addresses differently depending on the country.

### Installation

[](#installation)

Install the latest version with

```
$ composer require predicthq/address-formatter
```

### Examples

[](#examples)

You can use either the `Address` object or provide an array of address parts.

```
use PredictHQ\AddressFormatter\Address;

$a = new Address();
$a->setCity('Wellington')
  ->setCountry('New Zealand')
  ->setCountryCode('NZ')
  ->setCounty('Wellington City')
  ->setHouseNumber(53)
  ->setPostcode(6011)
  ->setRoad('Pirie Street')
  ->setState('Wellington')
  ->setSuburb('Mount Victoria');

$text = $a->format();

/**
 * Will display as:
 *
 * 53 Pirie Street
 * Mount Victoria
 * Wellington 6011
 * New Zealand
 */
echo $text;
```

Or, pass an array of address parts to the `Formatter`.

```
use PredictHQ\AddressFormatter\Formatter;

$address = [
  'city' => 'Wellington',
  'country' => 'New Zealand',
  'country_code' => 'NZ',
  'county' => 'Wellington City',
  'house_number' => 53,
  'postcode' => 6011,
  'road' => 'Pirie Street',
  'state' => 'Wellington',
  'suburb' => 'Mount Victoria',
];

/**
 * Will display as:
 *
 * 53 Pirie Street
 * Mount Victoria
 * Wellington 6011
 * New Zealand
 */
$f = new Formatter();
$actual = $f->formatArray($address);
```

### Tests

[](#tests)

Run tests using `./vendor/bin/phpunit`

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity46

Moderate usage in the ecosystem

Community16

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 94.9% 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 ~126 days

Recently: every ~189 days

Total

7

Last Release

2939d ago

PHP version history (2 changes)v1.0.0PHP &gt;=5.4.0

v1.0.2PHP &gt;=5.6.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/b156736f0655f024b987fe25fd0cab6f557d79324673acb9b5bf4638e8367100?d=identicon)[predicthq](/maintainers/predicthq)

---

Top Contributors

[![robertkern](https://avatars.githubusercontent.com/u/2150042?v=4)](https://github.com/robertkern "robertkern (37 commits)")[![kanariezwart](https://avatars.githubusercontent.com/u/606929?v=4)](https://github.com/kanariezwart "kanariezwart (1 commits)")[![tphipps](https://avatars.githubusercontent.com/u/2239044?v=4)](https://github.com/tphipps "tphipps (1 commits)")

---

Tags

addresspredicthq

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/predicthq-address-formatter/health.svg)

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

###  Alternatives

[friendsoftypo3/content-blocks

TYPO3 CMS Content Blocks - Content Types API | Define reusable components via YAML

101466.4k44](/packages/friendsoftypo3-content-blocks)[rcsofttech/audit-trail-bundle

Enterprise-grade, high-performance Symfony audit trail bundle. Automatically track Doctrine entity changes with split-phase architecture, multiple transports (HTTP, Queue, Doctrine), and sensitive data masking.

1155.2k](/packages/rcsofttech-audit-trail-bundle)[blackfire/player

A powerful web crawler and web scraper with Blackfire support

49517.1k](/packages/blackfire-player)[altis/local-server

Local Server module for Altis

18217.0k2](/packages/altis-local-server)

PHPackages © 2026

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