Coder Social home page Coder Social logo

isabella232 / php-postal Goto Github PK

View Code? Open in Web Editor NEW

This project forked from openvenues/php-postal

0.0 0.0 0.0 24 KB

PHP bindings to libpostal for for fast international street address parsing/normalization

License: MIT License

C 90.99% PHP 4.78% M4 4.23%

php-postal's Introduction

php-postal

Build Status

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

Usage

$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";
}

Installation

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

On CentOS/RHEL

sudo yum install curl autoconf automake libtool pkgconfig

On Mac OSX

sudo brew install curl autoconf automake libtool pkg-config

Installing libpostal

git clone https://github.com/openvenues/libpostal
cd libpostal
./bootstrap.sh
./configure --datadir=[...some dir with a few GB of space...]
make
sudo make install

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

Installing the PHP extension

git clone https://github.com/openvenues/php-postal
cd php-postal
phpize
./configure
make
sudo make install

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

[postal]
extension = postal.so

Compatibility

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 (https://github.com/morrislaptop) for adding PHP7 compatibility.

Tests

After compiling, run:

make test

php-postal's People

Contributors

albarrentine avatar elijahlynn avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.