PHPackages                             qfz9527/phpgeo - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. qfz9527/phpgeo

ActiveLibrary

qfz9527/phpgeo
==============

Simple Yet Powerful Geo Library

4.x-dev(5mo ago)01MITPHPPHP ^7.3 || ^8.0

Since Dec 18Pushed 5mo agoCompare

[ Source](https://github.com/qfz9527/phpgeo)[ Packagist](https://packagist.org/packages/qfz9527/phpgeo)[ Docs](https://phpgeo.marcusjaschen.de/)[ Fund](https://www.paypal.com/paypalme/mjaschen)[ GitHub Sponsors](https://github.com/mjaschen)[ RSS](/packages/qfz9527-phpgeo/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (3)Versions (2)Used By (0)

phpgeo - A Simple Geo Library for PHP
=====================================

[](#phpgeo---a-simple-geo-library-for-php)

phpgeo provides abstractions to geographical coordinates (including support for different ellipsoids) and allows you to calculate geographical distances between coordinates with high precision.

[![Latest Stable Version](https://camo.githubusercontent.com/7bcdfa16796c03c464441f35b15d1ef05ee4cfbe042976ecdefbb8a3abd6d703/68747470733a2f2f706f7365722e707567782e6f72672f6d6a61736368656e2f70687067656f2f76)](//packagist.org/packages/mjaschen/phpgeo)[![Total Downloads](https://camo.githubusercontent.com/391b2024ce87e16b960ea2640d65975fdc804586bae9612579978b5d8e40ba6c/68747470733a2f2f706f7365722e707567782e6f72672f6d6a61736368656e2f70687067656f2f646f776e6c6f616473)](//packagist.org/packages/mjaschen/phpgeo)[![phpgeo Tests](https://github.com/mjaschen/phpgeo/actions/workflows/ci.yml/badge.svg)](https://github.com/mjaschen/phpgeo/actions/workflows/ci.yml)[![Documentation Status](https://github.com/mjaschen/phpgeo/actions/workflows/docs.yml/badge.svg)](https://github.com/mjaschen/phpgeo/actions/workflows/docs.yml)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/9e761844b3fef919244941c0392f2be4a1703aa2919588ca17bb4cbb173e3efb/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d6a61736368656e2f70687067656f2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/mjaschen/phpgeo/?branch=master)[![License](https://camo.githubusercontent.com/8de3df1a6f808eec97fc5cd4fa0d7f02970add207f28bd094809d56c1a35ec14/68747470733a2f2f706f7365722e707567782e6f72672f6d6a61736368656e2f70687067656f2f6c6963656e7365)](//packagist.org/packages/mjaschen/phpgeo)

Requirements
------------

[](#requirements)

The minimum required PHP version is 8.2. *phpgeo* is tested up to PHP 8.5.

New features will only go into the main branch and won't be backported.

It's possible to install older versions of *phpgeo* for older PHP versions. Please refer to the following table for the compatibility matrix:

PHP Versionphpgeo VersionSupport StatusComposer Install8.56.x✅ active`composer require mjaschen/phpgeo`8.46.x✅ active`composer require mjaschen/phpgeo`8.36.x✅ active`composer require mjaschen/phpgeo`8.26.x✅ active`composer require mjaschen/phpgeo`8.15.x⚠️ security only`composer require mjaschen/phpgeo:^5.0`8.04.x⚠️ security only`composer require mjaschen/phpgeo:^4.0`7.44.x⚠️ security only`composer require mjaschen/phpgeo:^4.0`7.34.x⚠️ security only`composer require mjaschen/phpgeo:^4.0`7.23.x❌ end of life`composer require mjaschen/phpgeo:^3.0`7.12.x❌ end of life`composer require mjaschen/phpgeo:^2.0`7.02.x❌ end of life`composer require mjaschen/phpgeo:^2.0`5.61.x❌ end of life`composer require mjaschen/phpgeo:^1.0`5.51.x❌ end of life`composer require mjaschen/phpgeo:^1.0`5.41.x❌ end of life`composer require mjaschen/phpgeo:^1.0`Documentation
-------------

[](#documentation)

The documentation is available at [phpgeo.marcusjaschen.de](https://phpgeo.marcusjaschen.de/).

Installation
------------

[](#installation)

Using [Composer](https://getcomposer.org), just add it to your `composer.json` by running:

```
composer require mjaschen/phpgeo

```

Upgrading
---------

[](#upgrading)

Update the version constraint in the project's `composer.json` and run `composer update` or require the new version by running:

```
composer require mjaschen/phpgeo:^6.0
```

### Upgrading to 6.x

[](#upgrading-to-6x)

*phpgeo* has some breaking changes in the 6.x release line. Please refer to the following list to see what has changed and what you need to do to upgrade your code.

ChangeDescriptionAction`Line`, `Polygon`, and `Polyline` classes are now implementing a new interface`GeometryLinesInterface` provides the `getSegments()` method.There's no need to change anything if you don't extend those classes.`getBounds()` method was added to `GeometryInterface`Ensure your class has a `getBounds()` method if you implement `GeometryInterface`removed support for PHP 8.1Older PHP versions are no longer supported.Upgrade to at least PHP 8.2 or keep using phpgeo 5.x### Upgrading to 5.x

[](#upgrading-to-5x)

*phpgeo* has some breaking changes in the 5.x release line. Please refer to the following list to see what has changed and what you need to do to upgrade your code.

ChangeDescriptionAction`setPoint1()` and `setPoint2()` methods removed from `Line`The `Line` class now is immutable.Use the constructor to create a new instance of `Line`.removed support for PHP 7.3, 7.4 and 8.0Older PHP versions are no longer supported.Upgrade to at least PHP 8.1.License
-------

[](#license)

Starting with version 2.0.0 phpgeo is licensed under the MIT license. Older versions were GPL-licensed.

Features
--------

[](#features)

**Info:** Please visit the **[documentation site](https://phpgeo.marcusjaschen.de/)** for complete and up-to-date documentation with many examples!

phpgeo provides the following features (follow the links for examples):

- abstractions of several geometry objects ([coordinate/point](https://phpgeo.marcusjaschen.de/Geometries/Coordinate.html), [line](https://phpgeo.marcusjaschen.de/Geometries/Line.html), [polyline/GPS track](https://phpgeo.marcusjaschen.de/Geometries/Polyline.html), [polygon](https://phpgeo.marcusjaschen.de/Geometries/Polygon.html)
- support for different [ellipsoids](https://phpgeo.marcusjaschen.de/Geometries/Ellipsoid.html), e.g. WGS-84
- [length/distance/perimeter calculations](https://phpgeo.marcusjaschen.de/Calculations/Distance_and_Length.html)with different implementations (Haversine, Vincenty)
- [Geofence](https://phpgeo.marcusjaschen.de/Calculations/Geofence.html) calculation, i.e. answering the question "Is this point contained in that area/polygon?" and other [intersection](https://phpgeo.marcusjaschen.de/Comparisons/Intersections.html) checks between different geometries
- [formatting and output](https://phpgeo.marcusjaschen.de/Formatting_and_Output/index.html) of geometry objects (GeoJSON, nice strings, e. g. `18° 54′ 41″ -155° 40′ 42″`)
- calculation of [bearing angle between two points](https://phpgeo.marcusjaschen.de/Calculations/Bearing_and_Destination.html#page_Bearing-between-two-points)(spherical or with Vincenty's formula)
- calculation of a [destination point for a given starting point](https://phpgeo.marcusjaschen.de/Calculations/Bearing_and_Destination.html#page_Destination-point-for-given-bearing-and-distance), bearing angle, and distance (spherical or with Vincenty's formula)
- calculation of the [perpendicular distance between a point and a line](https://phpgeo.marcusjaschen.de/Calculations/Perpendicular_Distance.html)
- calculation of the [Cardinal Distances between two points](https://phpgeo.marcusjaschen.de/Calculations/Cardinal_Distance.html)
- getting segments of a [polyline](https://phpgeo.marcusjaschen.de/Geometries/Polyline.html#page_Segments)/[polygon](https://phpgeo.marcusjaschen.de/Geometries/Polygon.html#page_Segments),
- [reversing direction](https://phpgeo.marcusjaschen.de/Geometries/Polygon.html#page_Reverse-Direction)of polyline/polygon

Examples/Usage
--------------

[](#examplesusage)

This list is incomplete, please visit the **[documentation site](https://phpgeo.marcusjaschen.de/)**for the full monty of documentation and examples!

### Distance between two coordinates (Vincenty's Formula)

[](#distance-between-two-coordinates-vincentys-formula)

Use the calculator object directly:

```
