PHPackages                             salmanzafar/laravel-geo-fence - 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. salmanzafar/laravel-geo-fence

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

salmanzafar/laravel-geo-fence
=============================

A Laravel Library to calculate distance between two longitude and latitudes

v1.0.1(5y ago)157.5k11MITPHPPHP ^5.4.0 || ^7.0 || ^7.1 || ^7.2 || ^7.3 || ^7.4

Since Nov 14Pushed 4y ago2 watchersCompare

[ Source](https://github.com/salmanzafar949/Laravel-Geo-Fence)[ Packagist](https://packagist.org/packages/salmanzafar/laravel-geo-fence)[ Fund](https://www.buymeacoffee.com/salmanzafar949)[ Patreon](https://www.patreon.com/salmanzafar949)[ RSS](/packages/salmanzafar-laravel-geo-fence/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (1)Versions (4)Used By (1)

Laravel GeoFence Package
========================

[](#laravel-geofence-package)

A Laravel 5 and Laravel 6 package to calculate distance between two longitude and latitudes

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

[](#installation)

```
composer require salmanzafar/laravel-geo-fence

```

Enable the package (Optional)
-----------------------------

[](#enable-the-package-optional)

This package implements Laravel auto-discovery feature. After you install it the package provider and facade are added automatically for laravel &gt;= 5.5.

**This step is only required if you are using laravel version &lt;5.5**

To declare the provider and/or alias explicitly, then add the service provider to your config/app.php:

```
'providers' => [

        Salman\GeoFence\GeoFenceServiceProvider::class,
];

```

And then add the alias to your config/app.php:

```
'aliases' => [

       'GeoFence' => \Salman\GeoFence\Facades\GeoFence::class,
];

```

Configuration
-------------

[](#configuration)

Publish the configuration file

```
php artisan vendor:publish --provider="Salman\GeoFence\GeoFenceServiceProvider"

```

Config/geofence.php
-------------------

[](#configgeofencephp)

```
return [

    "unit" => "k"  // get result in kilometers
    // change unit to M/m to get result in Miles
];

```

#### Using in Controller

[](#using-in-controller)

```
use Salman\GeoFence\Service\GeoFenceCalculator;

 public function distance()
 {
        $d_calculator = new GeoFenceCalculator();

       $distance = $d_calculator->CalculateDistance('38.199020', '-77.969658', '37.090240', '-95.712891');

       return $distance;
 }

output: 1564.6

```

#### Measure Distance using Facade in Controller

[](#measure-distance-using-facade-in-controller)

```
use use GeoFence;

public function distance()
{
        $distance = GeoFence::CalculateDistance('38.199020', '-77.969658', '37.090240', '-95.712891');
        return $distance;
}

output: 1564.6

```

#### Measure Distance using command

[](#measure-distance-using-command)

```
php artisan geo:fence

**************************************************
* Welcome To Geo Fence Calculator                *
**************************************************

 Enter latitude 1: :
 > 38.199020

 Enter latitude 2: :
 > 37.090240

 Enter Longitude 1: :
 > -77.969658

 Enter Longitude 2: :
 > -95.712891

 Enter Unit k\M: :
 > K

Measured distance is: 1564.6 K
```

### Tested on php 7.3 and laravel 5.7 and also laravel 5.8 and laravel 6.\*

[](#tested-on-php-73-and-laravel-57-and-also-laravel-58-and-laravel-6)

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 85.7% 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 ~333 days

Total

2

Last Release

2091d ago

PHP version history (2 changes)v1.0.0PHP &gt;=5.4.0

v1.0.1PHP ^5.4.0 || ^7.0 || ^7.1 || ^7.2 || ^7.3 || ^7.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/a9db5166553b1ea30e083bbb5015efcc1b696995617bcfd5d74450d336b243dd?d=identicon)[salmanzafar949](/maintainers/salmanzafar949)

---

Top Contributors

[![salmanzafar40](https://avatars.githubusercontent.com/u/29972877?v=4)](https://github.com/salmanzafar40 "salmanzafar40 (12 commits)")[![salmanzafar949](https://avatars.githubusercontent.com/u/29015432?v=4)](https://github.com/salmanzafar949 "salmanzafar949 (2 commits)")

---

Tags

laravellaravel-packagephp7laravellaravel5laravel6laravel8laravel7geofence-laravelgeo-fence-laravellaravel-calculate-distance-between-two-pointslaravel geofence librarylaravel geo-fence libraryGeo Fencing laravel

### Embed Badge

![Health badge](/badges/salmanzafar-laravel-geo-fence/health.svg)

```
[![Health](https://phpackages.com/badges/salmanzafar-laravel-geo-fence/health.svg)](https://phpackages.com/packages/salmanzafar-laravel-geo-fence)
```

###  Alternatives

[salmanzafar/laravel-mqtt

A simple Laravel Library to connect/publish/subscribe to MQTT broker

102157.1k1](/packages/salmanzafar-laravel-mqtt)[brexis/laravel-workflow

Integerate Symfony Workflow component into Laravel.

287127.4k](/packages/brexis-laravel-workflow)[salmanzafar/laravel-geocode

A Laravel Library to find Lat and Long of a given Specific Address

154.4k](/packages/salmanzafar-laravel-geocode)[misterphilip/maintenance-mode

An enhanced drop-in replacement for Laravel's maintenance mode

120178.0k](/packages/misterphilip-maintenance-mode)

PHPackages © 2026

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