Download the PHP package happenv-com/address-splitter without Composer
On this page you can find all versions of the php package happenv-com/address-splitter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package address-splitter
Address Splitter
A PHP library for parsing addresses into components: street, building number, and apartment number.
Supports country-specific address formats for 27 European countries and includes generic fallback strategies for unknown formats.
Installation
Requirements: PHP 8.0+
Quick Start
Parse Result
The split() method returns a ParsedAddress object:
If no strategy matches the address, the entire text is returned as street.
Supported Countries
The library includes optimized parsers for the following countries:
| Code | Country | Example Formats |
|---|---|---|
PL |
Poland | ul. Marszałkowska 123/45, al. Jana Pawła II 15, 3 Maja 10 |
DE |
Germany | Hauptstraße 42a, Musterweg 12-14 |
AT |
Austria | Ringstraße 15/3, Hauptplatz 1 |
CH |
Switzerland | Bahnhofstrasse 10, Rue de Lausanne 25 |
FR |
France | 15 Rue de la Paix, 25 bis Avenue des Champs-Élysées |
BE |
Belgium | Rue Haute 120, Hoogstraat 45 |
LU |
Luxembourg | 12 Avenue de la Liberté |
NL |
Netherlands | Kalverstraat 152-III, 1e Helmersstraat 25 |
GB |
United Kingdom | 221B Baker Street, Flat 5, 10 Downing Street |
IE |
Ireland | 42 O'Connell Street Upper |
IT |
Italy | Via Roma 15/A, Piazza Duomo 1 |
ES |
Spain | Calle Mayor 25, 3º B, Avenida de la Constitución 10 |
PT |
Portugal | Rua Augusta 100, 2º Esq, Avenida da Liberdade 50 |
SE |
Sweden | Kungsgatan 44, 2 tr, Storgatan 12 lgh 1001 |
FI |
Finland | Mannerheimintie 5 A 12, Aleksanterinkatu 10 |
DK |
Denmark | Strøget 15, 2. sal, Vesterbrogade 100 |
CZ |
Czech Republic | Václavské náměstí 123/45, Karlova 10 |
SK |
Slovakia | Hlavná 50/12, Obchodná 15 |
HU |
Hungary | Andrássy út 60. 3/5, Váci utca 12 |
LT |
Lithuania | Gedimino pr. 15-20, Vilniaus g. 25 |
LV |
Latvia | Brīvības iela 100-5, Rīgas iela 12 |
EE |
Estonia | Viru tänav 15-3, Tartu mnt 50 |
RO |
Romania | Strada Victoriei nr. 10, ap. 5, Bulevardul Unirii 25 |
BG |
Bulgaria | бул. Витоша 15, ап. 3, ул. Шипка 10 |
HR |
Croatia | Ilica 25/3, Trg bana Jelačića 10 |
SI |
Slovenia | Slovenska cesta 50/2, Prešernov trg 5 |
GR |
Greece | Λεωφόρος Αθηνών 100, Οδός Ερμού 25 |
MT |
Malta | 15 Republic Street, Flat 3, 20 Main Street |
CY |
Cyprus | 25 Makarios Avenue, 10 Ledra Street |
Configuration
Default Configuration
Empty Configuration
Adding Strategies
Custom Fallback Strategies
Fallback strategies are used when:
- No country code is provided
- No strategies are defined for the given country
Default fallback strategies:
SlashApartmentStrategy- formats with/as apartment separatorCommaApartmentStrategy- formats with,as separatorDashApartmentStrategy- formats with-as separatorStreetFirstStrategy- street before numberNumberFirstStrategy- number before street
External Strategies (API)
For addresses that cannot be parsed by local strategies, you can enable external APIs.
Important: External strategies use "first match wins" logic - the first strategy that returns a result wins. This prevents unnecessary API costs.
Google Address Validation API
OpenAI API
Multiple External Strategies
Enabling/Disabling External Strategies
Custom Parsing Strategies
You can create custom strategies by implementing the AddressParsingStrategyInterface:
Or extend the AbstractParsingStrategy class:
HTTP Clients
The library provides two HTTP clients for external strategies:
CurlHttpClient
Native PHP client with no external dependencies:
GuzzleHttpClient
Wrapper for Guzzle HTTP (requires guzzlehttp/guzzle):
Custom HTTP Client
Implement HttpClientInterface:
Architecture
The library uses a three-tier parsing strategy:
- Country strategies - country-specific parsers (all results →
BestResultSelector) - Fallback strategies - generic parsers when no country code (all results →
BestResultSelector) - External strategies - paid APIs (first match wins - cost minimization)
Testing
License
MIT License