meezaan / haversini-formula
This PHP class can replace the Google Distance Matrix to calculate the distance between two points using latitude and longitude. It will prevent you to do massive requests to Google servers and enhance your service performance.
This package's canonical repository appears to be gone and the package has been frozen as a result. Email us for help if needed.
Requires
- php: >=8.1
- meezaan/unit-converter: dev-master
Requires (Dev)
- phpunit/php-code-coverage: ^9.1
- phpunit/phpunit: ^9.0
- symfony/var-dumper: ^4.3
This package is not auto-updated.
Last update: 2026-02-07 09:07:23 UTC
README
Calculates de distance between two geocode points 📌🗺
Formed from rafaelfragoso/haversini-formula which appears to not be maintained anymore.
This package has been updated to work with PHP 8.4+.
How to use it:
Install the library via Composer or clone the repo:
composer require meezaan/haversini-formula
After the installation is complete, you can load the class and start using it.
<?php
use Haversini\Haversini;
/*
* Calculate distance from Rio de Janeiro to São Paulo
* Rio: -22.906847, -43.172896
* São Paulo: -23.550520, -46.633309
*/
Haversini::calculate(
-22.906847,
-43.172896,
-23.550520,
-46.633309,
'mi' // Output length unit
);
Running tests
make test or make test-coverage
XDebug is required for test coverage!
Authors
- Rafael Fragoso - Initial work
- Leonardo Carmo - Version 2
- Mamluk LLC - Version 2+
See also the list of contributors who participated in this project.
License
This project is licensed under the MIT License - see the LICENSE.md file for details