PHPackages                             jord-jd/php-distance - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. jord-jd/php-distance

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

jord-jd/php-distance
====================

Allows for calculation of many types of distance between points

v2.0.0(3mo ago)311[2 issues](https://github.com/Jord-JD/php-distance/issues)[1 PRs](https://github.com/Jord-JD/php-distance/pulls)2LGPL-3.0-onlyPHPPHP &gt;=7.0.0

Since Nov 25Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/Jord-JD/php-distance)[ Packagist](https://packagist.org/packages/jord-jd/php-distance)[ GitHub Sponsors](https://github.com/DivineOmega)[ RSS](/packages/jord-jd-php-distance/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (1)Versions (4)Used By (2)

PHP Distance
============

[](#php-distance)

[![Build Status](https://camo.githubusercontent.com/a55798b6ef452872e5cfbf57e8d49b512ed352494e97886062aa76310fed06a4/68747470733a2f2f7472617669732d63692e6f72672f4a6f72642d4a442f7068702d64697374616e63652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Jord-JD/php-distance)[![Coverage Status](https://camo.githubusercontent.com/dd4c211031528fdd56f5f85730dd3d94835a8dff8ba6a8b6e2a6bed546bc3434/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f4a6f72642d4a442f7068702d64697374616e63652f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/Jord-JD/php-distance?branch=master)[![Packagist](https://camo.githubusercontent.com/286821d32fc71435311bf4a57839f4e43cb603715d5c8be9bf6cfcaa26dcfaaa/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6a6f72642d6a642f7068702d64697374616e63652e737667)](https://packagist.org/packages/jord-jd/php-distance/stats)

The PHP Distance library allows for calculation of many types of distance between points.

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

[](#installation)

PHP Distance can be easily installed using Composer. Just run the following command from the root of your project.

```
composer require jord-jd/php-distance

```

If you have never used the Composer dependency manager before, head to the [Composer website](https://getcomposer.org/) for more information on how to get started.

Usage
-----

[](#usage)

See the following code snippet that demonstates how to use this library.

```
$a = new Point($x1, $y1);
$b = new Point($x2, $y2);
$c = new Point($x3, $y3, $z3); # Infinite dimensions supported by some distance types

$distanceType = new Euclidean();
$distanceType = new EuclideanSquare();
$distanceType = new Haversine();	# For GPS coordinates (latitude and longitude)

$distance = (new Distance())
		->type(new Euclidean())	# Type is optional, and defaults to Euclidean distance
		->from($a)
		->to($b)
		->get();
```

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance69

Regular maintenance activity

Popularity6

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 81.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1319 days

Total

3

Last Release

92d ago

Major Versions

v1.0.1 → v2.0.02026-02-14

### Community

Maintainers

![](https://www.gravatar.com/avatar/c580cdf7c14898fff179cdfc1085892091d5d2f49d917873a12365af9ac77c93?d=identicon)[Jord-JD](/maintainers/Jord-JD)

---

Top Contributors

[![Jord-JD](https://avatars.githubusercontent.com/u/650645?v=4)](https://github.com/Jord-JD "Jord-JD (13 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (3 commits)")

---

Tags

distanceeuclidean-distancehaversine-distancephp-library

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/jord-jd-php-distance/health.svg)

```
[![Health](https://phpackages.com/badges/jord-jd-php-distance/health.svg)](https://phpackages.com/packages/jord-jd-php-distance)
```

###  Alternatives

[harvesthq/chosen

Chosen is a JavaScript plugin that makes select boxes user-friendly. It is currently available in both jQuery and Prototype flavors.

385.2M12](/packages/harvesthq-chosen)[niiknow/bayes

a machine learning lib

6950.0k](/packages/niiknow-bayes)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
