PHP bindings to libpostal for for fast international street address parsing/normalization
Clone or download
albarrentine Merge pull request #12 from ElijahLynn/patch-1
Update Parser example to use $component['value']
Latest commit 06d39d2 May 5, 2018


Build Status

These are the official PHP bindings to libpostal, a C library for fast international street address parsing and normalization.


$expansions = Postal\Expand::expand_address("Quatre vingt douze Ave des Champs-Élysées");
foreach ($expansions as $expansion) {
    echo "$expansion\n";

$parsed = Postal\Parser::parse_address("The Book Club 100-106 Leonard St, Shoreditch, London, Greater London, EC2A 4RH, United Kingdom");
foreach ($parsed as $component) {
    echo "{$component['label']}: {$component['value']}\n";


Before using the PHP bindings, you must install the libpostal C library. Make sure you have the following prerequisites:

On Ubuntu/Debian

sudo apt-get install curl autoconf automake libtool pkg-config


sudo yum install curl autoconf automake libtool pkgconfig

On Mac OSX

sudo brew install curl autoconf automake libtool pkg-config

Installing libpostal

git clone
cd libpostal
./configure --datadir=[...some dir with a few GB of space...]
sudo make install

# On Linux it's probably a good idea to run
sudo ldconfig

Installing the PHP extension

git clone
cd php-postal
sudo make install

This will build a '' shared extension. Add it to php.ini using:

extension =


php-postal currently supports PHP 5.5, 5.6 and PHP 7. HipHop/HHVM uses a different process for extensions (C++) so it would be best to implement that as a separate project.

Special thanks to Craig Morris ( for adding PHP7 compatibility.


After compiling, run:

make test