https://github.com/labrodev/haversine
PHP 8.1+ utility library that provides a lightweight method to calculate the great-circle distance between two geographic coordinates using the Haversine formula.
https://github.com/labrodev/haversine
composer-library composer-package distance-calculation distance-measures haversine-distance haversine-formula labrodev latitude-and-longitude php php-library php-package php-utility php8 webdevelopment
Last synced: 3 months ago
JSON representation
PHP 8.1+ utility library that provides a lightweight method to calculate the great-circle distance between two geographic coordinates using the Haversine formula.
- Host: GitHub
- URL: https://github.com/labrodev/haversine
- Owner: labrodev
- License: mit
- Created: 2025-06-29T12:10:37.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2025-06-29T12:36:33.000Z (3 months ago)
- Last Synced: 2025-06-29T13:40:31.784Z (3 months ago)
- Topics: composer-library, composer-package, distance-calculation, distance-measures, haversine-distance, haversine-formula, labrodev, latitude-and-longitude, php, php-library, php-package, php-utility, php8, webdevelopment
- Language: PHP
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.MD
- License: LICENSE
Awesome Lists containing this project
README
# PHP Haversine Distance Calculator
**Labrodev\Haversine** is a strict PHP 8.1+ utility library that provides a lightweight method to calculate the great-circle distance between two geographic coordinates using the Haversine formula.
## Features
- Calculates accurate distance between two latitude/longitude points
- Returns result in kilometers
- Based on the Haversine formula (spherical Earth model)
- Fully static and type-safe class
- Lightweight, dependency-free implementation
- Includes PHPUnit and PHPStan support for testing and analysis## Installation
```
composer require labrodev/haversine
```## Usage
```php
use Labrodev\Haversine\Calculator;// Distance in kilometers between Paris and Frankfurt
$distance = Calculator::haversineDistance(48.8566, 2.3522, 50.1109, 8.6821);echo $distance; // e.g., 478.5
```## Testing
To run tests:
```
composer install
composer test
```## Static Analysis
To run static analysis using PHPStan:
```
composer install
composer analyse
```> Configuration is located in `phpstan.neon.dist`
## Security
If you discover a security vulnerability within this package, **please contact us immediately at [contact@labrodev.com](mailto:contact@labrodev.com)**. All security-related issues will be handled privately and promptly.
## Credits
This package is maintained by **Labrodev** — Laravel & PHP development studio.
[https://github.com/labrodev](https://github.com/labrodev)## Feedback
If you have any questions, suggestions, or have found an error — feel free to open an issue or contact us:
**contact@labrodev.com****License:** MIT