bureaupartners/extract-address-from-text
With this package you can extract the address from a unformatted text string
10,569
3
| Install | |
|---|---|
composer require bureaupartners/extract-address-from-text |
|
| Latest Version: | v3.0.0 |
| PHP: | ^7.2 | ^8.0 |
| License: | MIT |
| Last Updated: | Oct 29, 2026 |
| Links: | GitHub · Packagist |
Maintainer: markhameetman
Extract address from text
With this package you can extract the address from a unformatted text string
Installation
Install composer packages
composer require bureaupartners/extract-address-from-text
Usage
use BureauPartners\ExtractAddressFromText\AddressExtractor;
$extractor = new AddressExtractor($address['text']);
$extractor->getAddress(); // Get all information
$extractor->getRecipient();
$extractor->getStreet();
$extractor->getHouseNumber();
$extractor->getHouseNumberAddition();
$extractor->getPostalCode();
$extractor->getCity();
$extractor->getCountry()['code'];
The second argument is the country to assume when the address has no country
line (default NL):
$extractor = new AddressExtractor($address['text'], 'BE');
Countries
Postcodes are recognized for every European country. The country comes from, in this order:
- the country line, in most languages and also as an ISO code on the last line;
- a postcode of the assumed country;
- a country written behind the city ("1010 Wien, Austria");
- a postcode that can only belong to one country ("SW7 5DP", "00-468", "D-10117").
When none of these apply, getCountry()['code'] is an empty string.
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
License
See LICENSE.md
Related Packages
nonsapiens/realaddressfactory
Creates real-world street addresses from Google Maps, to use in database seeding...
13,173
53
Version History
| Version | Released | PHP | License |
|---|---|---|---|
| v3.0.0 | ^7.2 | | MIT | |
| v2.1.0 | ^7.2 | | MIT | |
| v2.0.0 | ^7.2 | | MIT | |
| v1.7.0 | ^7.2 | | MIT | |
| v1.6.1 | ^7.2 | | MIT | |
| v1.6.0 | ^7.2 | | MIT | |
| v1.5.4 | ^7.2 | | MIT | |
| v1.5.3 | ^7.2 | | MIT | |
| v1.5.2 | ^7.2 | | MIT | |
| v1.5.1 | ^7.2 | | MIT | |
| v1.5.0 | ^7.2 | | MIT | |
| v1.4.1 | ^7.2 | | MIT | |
| v1.4.0 | ^7.2 | | MIT | |
| 1.3.0 | ^7.2 | | MIT | |
| v1.2.0 | ^7.2 | | MIT | |
| v1.1.2 | ^7.2 | MIT | |
| v1.1.1 | ^7.2 | MIT | |
| v1.1.0 | ^7.2 | MIT | |
| v1.0.1 | ^7.2 | MIT | |
| v1.0.0 | ^7.2 | MIT | |
| v0.1.0 | ^7.2 | MIT |