PHPackages                             michielgerritsen/extract-address-parts - 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. michielgerritsen/extract-address-parts

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

michielgerritsen/extract-address-parts
======================================

Get the (Dutch) street, house number, and extension from a concatenated string

v1.0.6(1y ago)911.9k↓57.8%1WTFPLPHPPHP ^7.0|^8.0CI passing

Since Jun 25Pushed 1w ago1 watchersCompare

[ Source](https://github.com/michielgerritsen/extract-address-parts)[ Packagist](https://packagist.org/packages/michielgerritsen/extract-address-parts)[ RSS](/packages/michielgerritsen-extract-address-parts/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (4)Dependencies (1)Versions (8)Used By (0)

[![](https://github.com/michielgerritsen/extract-address-parts/workflows/Test/badge.svg)](https://github.com/michielgerritsen/extract-address-parts/workflows/Test/badge.svg)

Extract information from Dutch addresses
========================================

[](#extract-information-from-dutch-addresses)

I have been in this situation multiple times: You need to provide a housenumber and addition for some API. But the provided dataset only has the complete address. This library tries to solve this issue. For instance:

- Kerkstraat 95A
    - Street: `Kerkstraat`
    - Housenumber: `95`
    - Addition: `A`

This is a lightweight repository, it has no runtime dependencies beyond the `mbstring` extension.

Upgrading from 1.x? See [UPGRADE.md](UPGRADE.md).

Requirements
------------

[](#requirements)

PHP 8.1 or higher, with the `mbstring` extension. Version 1.x supports PHP 7.0 and up.

Installation
------------

[](#installation)

```
composer require michielgerritsen/extract-address-parts

```

Usage
-----

[](#usage)

```
use MichielGerritsen\ExtractAddressParts\CombinedAddressExtraction;
use MichielGerritsen\ExtractAddressParts\Exceptions\AddressExtractionError;
use MichielGerritsen\ExtractAddressParts\VO\AddressExtractionResult;

try {
    /** @var AddressExtractionResult $result */
    $result = CombinedAddressExtraction::create()->process('Kerkstraat 95A');
} catch (AddressExtractionError $exception) {
    die('Uh oh, this address seems to be invalid.');
}

$result->getStreet(); // Kerkstraat
$result->getHousenumber(); // 95
$result->getAddition(); // A
```

Pass an array when the address is split over multiple lines:

```
$result = CombinedAddressExtraction::create()->process(['Kerkstraat', '95A']);
```

Choosing a strategy
-------------------

[](#choosing-a-strategy)

StrategyHow it worksUse when`CombinedAddressExtraction`Tries `PrecisionAddressExtraction` first and falls back to `AddressExtraction`.You want the best result available. Start here.`PrecisionAddressExtraction`Matches against a list of all known Dutch streets.You only want addresses whose street actually exists, and prefer an exception over a guess.`AddressExtraction`Matches the shape of an address with a regular expression.The address may be outside the Netherlands, or you accept unverified input.```
use MichielGerritsen\ExtractAddressParts\AddressExtraction;
use MichielGerritsen\ExtractAddressParts\PrecisionAddressExtraction;

$result = (new AddressExtraction())->process('Kerkstraat 95A');
$result = (new PrecisionAddressExtraction())->process('Kerkstraat 95A');
```

`CombinedAddressExtraction::create()` wires up the two default strategies. To use your own, pass any implementations of `AddressExtractionInterface` to the constructor. They are attempted in the order you give them:

```
new CombinedAddressExtraction(new PrecisionAddressExtraction(), new AddressExtraction());
```

Knowing how reliable a result is
--------------------------------

[](#knowing-how-reliable-a-result-is)

`PrecisionAddressExtraction` verifies the street against a list of known Dutch streets, while `AddressExtraction` only checks that the input has the shape of an address. Because `CombinedAddressExtraction` falls back silently, a guess would otherwise be indistinguishable from a verified match. `getExtractionMethod()` tells you which of the two produced the result:

```
use MichielGerritsen\ExtractAddressParts\ExtractionMethod;

$result = CombinedAddressExtraction::create()->process('Qwertyuiopasdf 12');

$result->getExtractionMethod(); // ExtractionMethod::Pattern
$result->getExtractionMethod()->isVerified(); // false, the street was never confirmed to exist
```

That street does not exist, but it has the shape of an address, so the regex accepts it. Use `isVerified()` to decide what to trust, for example to accept verified addresses automatically and queue the rest for review.

Errors
------

[](#errors)

An `AddressExtractionError` is thrown when:

- no house number can be found, such as `Kerkstraat` on its own;
- the street is not recognised (`PrecisionAddressExtraction` only);
- the input is a postbox, such as `Postbus 1234`, which has no street or house number.

The street list
---------------

[](#the-street-list)

`PrecisionAddressExtraction` matches against the files in `addresses/`, one per starting character, holding every street name in the Netherlands in lowercase UTF-8. The data comes from the Kadaster BAG registry through the [PDOK Locatieserver](https://www.pdok.nl/).

Regenerate it with:

```
composer update-addresses

```

The script walks all 342 gemeenten, because the API returns at most 100 rows per request and refuses an offset above 10000. It takes a few minutes, and refuses to write anything if it collects implausibly few streets, so a failed run cannot leave you with a truncated list.

License
-------

[](#license)

The code is [MIT](LICENSE) licensed.

The street names in `addresses/` are not. They come from the Basisregistratie Adressen en Gebouwen of the Dutch [Kadaster](https://www.kadaster.nl/), retrieved through [PDOK](https://www.pdok.nl/), and are licensed [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/). Keep that attribution if you redistribute the data.

Contributing
------------

[](#contributing)

Pull the repository and run `composer install`.

```
composer test     # run the test suite
composer analyse  # run PHPStan

```

Both run in CI against every supported PHP version.

###  Health Score

50

—

FairBetter than 95% of packages

Maintenance75

Regular maintenance activity

Popularity32

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 76.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 ~303 days

Recently: every ~373 days

Total

7

Last Release

425d ago

PHP version history (2 changes)v1.0.0PHP ^7.0

v1.0.2PHP ^7.0|^8.0

### Community

Maintainers

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

---

Top Contributors

[![michielgerritsen](https://avatars.githubusercontent.com/u/5858697?v=4)](https://github.com/michielgerritsen "michielgerritsen (30 commits)")[![rikwillems](https://avatars.githubusercontent.com/u/5927342?v=4)](https://github.com/rikwillems "rikwillems (7 commits)")[![rikwillems-redkiwi](https://avatars.githubusercontent.com/u/102238548?v=4)](https://github.com/rikwillems-redkiwi "rikwillems-redkiwi (2 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/michielgerritsen-extract-address-parts/health.svg)

```
[![Health](https://phpackages.com/badges/michielgerritsen-extract-address-parts/health.svg)](https://phpackages.com/packages/michielgerritsen-extract-address-parts)
```

PHPackages © 2026

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