This package is abandoned and no longer maintained. No replacement package was suggested.

Pop Geo Component for Pop PHP Framework

2.1.0p1 2016-07-08 04:52 UTC

This package is auto-updated.

Last update: 2019-02-20 19:33:23 UTC


Build Status Coverage Status


The pop-geo component v2.1.0 is now end-of-life and will no longer be supported due to lack of support for the GeoIP extension in PHP 7.


pop-geo is a component for leveraging the GeoIP databases and calculating information about IP location as well as distances between sets of longitude and latitude points.

pop-geo is a component of the Pop PHP Framework.


Install pop-geo using Composer.

composer require popphp/pop-geo


If the GeoIP extension and databases are installed, it will autodetect information based on the IP.

use Pop\Geo\Geo;

$nola = new Geo();

echo $nola->getLatitude();  // 29.9546500
echo $nola->getLongitude(); // -90.0750700
Calculate the distance between to sets of points

You can give it a second set of coordinates to calculate the distance between them:

$houston = new Geo([
    'latitude'  => 29.7632800,
    'longitude' => -95.3632700

echo $nola->distanceTo($houston);          // Outputs '317.11' miles
echo $nola->distanceTo($houston, 2, true); // Outputs '510.34' kilometers

You can also manually give it 2 sets of points as well:

use Pop\Geo\Geo;

$nola = [
    'latitude'  => 29.9546500,
    'longitude' => -90.0750700

$houston = [
    'latitude'  => 29.7632800,
    'longitude' => -95.3632700

echo Geo::calculateDistance($nola, $houston); // Outputs '317.11' miles