PHPackages                             ballen/distical - 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. ballen/distical

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

ballen/distical
===============

A distance (Lat/Long) calculation library for PHP

3.1.0(2y ago)40199.2k↓54.1%7[1 PRs](https://github.com/allebb/distical/pulls)2MITPHPPHP &gt;=7.3.0CI failing

Since Nov 24Pushed 5mo ago2 watchersCompare

[ Source](https://github.com/allebb/distical)[ Packagist](https://packagist.org/packages/ballen/distical)[ Docs](http://github.com/allebb/distical)[ RSS](/packages/ballen-distical/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (10)Dependencies (1)Versions (15)Used By (2)

Distical
========

[](#distical)

[![Build](https://github.com/allebb/distical/workflows/build/badge.svg)](https://github.com/allebb/distical/actions)[![Code Coverage](https://camo.githubusercontent.com/3bb2adb8be2f950a488af4b79220ed5cb37ed30402290deb970fbc3439ea70e9/68747470733a2f2f636f6465636f762e696f2f67682f616c6c6562622f646973746963616c2f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/allebb/distical)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/3ed50865054710f086760a1981bd4ab7944ead996fc309e5803da6e68f99738a/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f616c6c6562622f646973746963616c2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/allebb/distical/?branch=master)[![Code Climate](https://camo.githubusercontent.com/fc1578149a053426ac2c0a980142126dcc0e4d60bc67d2dee45b548939eec718/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f616c6c6562622f646973746963616c2f6261646765732f6770612e737667)](https://codeclimate.com/github/allebb/distical)[![Latest Stable Version](https://camo.githubusercontent.com/c2aea04b59c22a7ebc3a7c8c36c815d307f1d26b6d118b37557f76c4f027b9d3/68747470733a2f2f706f7365722e707567782e6f72672f62616c6c656e2f646973746963616c2f762f737461626c65)](https://packagist.org/packages/ballen/distical) [![Latest Unstable Version](https://camo.githubusercontent.com/0395407f34a5c61b6704afe854deb24d9eb0e8affc20faaeeabee5b32d5bd28e/68747470733a2f2f706f7365722e707567782e6f72672f62616c6c656e2f646973746963616c2f762f756e737461626c65)](https://packagist.org/packages/ballen/distical) [![License](https://camo.githubusercontent.com/83f6c6a2c76565f236cc8e7e3a3a2a655bf04d1e7a17b796b338b891ed092097/68747470733a2f2f706f7365722e707567782e6f72672f62616c6c656e2f646973746963616c2f6c6963656e7365)](https://packagist.org/packages/ballen/distical)

Distical is a PHP distance calculator library of which, amongst other things is developed to calculate the distance between two or more lat/long coordinates.

License
-------

[](#license)

This client library is released under the [MIT license](LICENSE).

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

[](#requirements)

This library is unit tested against PHP 7.3, 7.4, 8.0, 8.1 and 8.2!

If you need to use an older version of PHP, you should instead install the 3.x version of this library (see below for details).

Setup
-----

[](#setup)

I highly recommend the use of [Composer](https://getcomposer.org/) when installing and using this library, it is not mandatory however and you can use a provided 'include' script to load in this library if required.

### Composer

[](#composer)

Simply require this package as follows:

```
composer require ballen/distical
```

**If you need to use an older version of PHP, version 2.x.x supports PHP 5.3, 5.4, 5.5, 5.6, 7.0, 7.1 and 7.2, you can install this version using Composer with this command instead:**

```
composer require ballen/disitcal ^2.0
```

```
composer install

```

### Standalone

[](#standalone)

You can use the library "standalone" by downloading it from the [GitHub releases section](https://github.com/allebb/distical/releases), extracting the files to a place on your server and then adding the "include" into your code like so:

```
require_once 'path/to/Distical/Distical.inc.php';
```

Examples
--------

[](#examples)

```
use Ballen\Distical\Calculator as DistanceCalculator;
use Ballen\Distical\Entities\LatLong;

// Set our Lat/Long coordinates
$ipswich = new LatLong(52.057941, 1.147172);
$london = new LatLong(51.507608, -0.127822);

// Get the distance between these two Lat/Long coordinates...
$distanceCalculator = new DistanceCalculator($ipswich, $london);

// You can then compute the distance...
$distance = $distanceCalculator->get();
// you can also chain these methods together eg. $distanceCalculator->get()->asMiles();

// We can now output the miles using the asMiles() method, you can also calculate and use asKilometres() or asNauticalMiles() as required!
echo 'Distance in miles between Central Ipswich and Central London is: ' . $distance->asMiles();
```

A set of working examples including multi-point calculations can be found in the `/examples` directory, feel free to browse or run them!

Tests and coverage
------------------

[](#tests-and-coverage)

This library is fully unit tested using [PHPUnit](https://phpunit.de/).

I use GitHub Actions for continuous integration, which triggers tests for PHP 7.3, 7.4, 8.0, 8.1 and 8.2 everytime a commit is pushed.

If you wish to run the tests yourself you should run the following:

```
# Install the Distical Library with the 'development' packages this then including PHPUnit!
composer install

# Now we run the unit tests (from the root of the project) like so:
./vendor/bin/phpunit

```

Code coverage can also be ran but requires XDebug installed...

```
./vendor/bin/phpunit --coverage-html ./report

```

Support
-------

[](#support)

I am happy to provide support via. my personal email address, so if you need a hand drop me an email at: .

###  Health Score

49

—

FairBetter than 94% of packages

Maintenance49

Moderate activity, may be stable

Popularity46

Moderate usage in the ecosystem

Community19

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 90.5% 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 ~272 days

Recently: every ~262 days

Total

13

Last Release

969d ago

Major Versions

1.1.0 → 2.0.02015-05-15

2.0.7 → 3.0.02020-12-23

PHP version history (2 changes)1.1.0PHP &gt;=5.3.0

3.0.0PHP &gt;=7.3.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/4729a376aa8281d9456a90c000e991aa605c96f15251469acd5a7a5c6cdde2e6?d=identicon)[allebb](/maintainers/allebb)

---

Top Contributors

[![allebb](https://avatars.githubusercontent.com/u/767628?v=4)](https://github.com/allebb "allebb (86 commits)")[![Jagdish-J-P](https://avatars.githubusercontent.com/u/20887370?v=4)](https://github.com/Jagdish-J-P "Jagdish-J-P (7 commits)")[![JeroenVanOort](https://avatars.githubusercontent.com/u/5616838?v=4)](https://github.com/JeroenVanOort "JeroenVanOort (1 commits)")[![kevindaus](https://avatars.githubusercontent.com/u/10745021?v=4)](https://github.com/kevindaus "kevindaus (1 commits)")

---

Tags

calculatordistancelatlatitudelnglongitudemilesnauticalphpmappingcalculatorlatitudedistancegpslonglongditudelatlng

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ballen-distical/health.svg)

```
[![Health](https://phpackages.com/badges/ballen-distical/health.svg)](https://phpackages.com/packages/ballen-distical)
```

###  Alternatives

[mjaschen/phpgeo

Simple Yet Powerful Geo Library

1.6k9.3M28](/packages/mjaschen-phpgeo)[cuyz/valinor

Dependency free PHP library that helps to map any input into a strongly-typed structure.

1.5k13.2M174](/packages/cuyz-valinor)[akuechler/laravel-geoly

Perform fast and efficient radius searches on your Laravel Eloquent models.

4163.1k](/packages/akuechler-laravel-geoly)[laravie/geotools

Geo-related tools PHP 7+ library

18136.3k1](/packages/laravie-geotools)[0x13a/geodistance-php

Calculate geodistance between two points, latitude and longitude

3120.6k](/packages/0x13a-geodistance-php)

PHPackages © 2026

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