PHPackages                             will-belo/geo-location-service - 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. will-belo/geo-location-service

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

will-belo/geo-location-service
==============================

Serviço para encontrar lojas mais próximas baseado em geolocalização

v1.0.1(1y ago)02MITPHPPHP &gt;=8.0

Since Mar 25Pushed 1y ago1 watchersCompare

[ Source](https://github.com/will-belo/Geo-location-service)[ Packagist](https://packagist.org/packages/will-belo/geo-location-service)[ RSS](/packages/will-belo-geo-location-service/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (3)Versions (3)Used By (0)

Geolocation Service
===================

[](#geolocation-service)

Este projeto contém serviços para encontrar a loja mais próxima usando coordenadas geográficas.

📦 Instalação
------------

[](#-instalação)

via Composer:

```
    composer require will-belo/geo-location-service
```

via git:

1. Clone o repositório:

```
    git clone https://github.com/seu-usuario/geo-location-service.git
    cd geo-location-service
```

2. Instale as dependências do Laravel (se aplicável):

```
    composer install
```

⚙️ Configuração
---------------

[](#️-configuração)

1. Adicione as configurações no `.env`Adicione as seguintes variáveis ao seu arquivo `.env`

```
    GEOLOCATION_RADIUS=6371
    GEOLOCATION_CACHE_DURATION=60
    GEOLOCATION_GOOGLE_API_KEY=
    GEOLOCATION_ADDRESS_MODEL=App\Models\Address # Altere para o seu modelo de endereço, se necessário
```

2. Configure sua model de endereço O pacote pode ser usado com qualquer model, contanto que ela tenha as seguintes características: ✅ Colunas `latitude` e `longitude` (em sua tabela de endereços) ✅ Um relacionamento `relatedEntity()` que aponta para a entidade que deseja associar ao endereço (ex. `Store`, `Shop`, etc.).

```
    namespace App\Models;

    use Illuminate\Database\Eloquent\Model;

    class MyAddress extends Model
    {
        protected $table = 'addresses'; // Nome da tabela

        // Relacionamento com a entidade associada, como uma loja
        public function relatedEntity()
        {
            return $this->hasOne(\App\Models\Store::class); // Modelo que você deseja associar
        }
    }
```

3. Configuração de Cache Certifique-se de que a configuração de cache esteja corretamente definida no arquivo `.env` e em `config/cache.php`.

🚀 Uso
-----

[](#-uso)

1. Encontrando a entidade mais próxima Agora você pode usar o serviço de geolocalização para encontrar a entidade (por exemplo, uma loja) mais próxima de uma latitude e longitude específicas. Exemplo de uso:

```
    use GeoLocationService\Services\GeocodingService;

    $geoService = new GeocodingService();
    $latitude = -23.550520; // Exemplo de latitude
    $longitude = -46.633308; // Exemplo de longitude

    $nearestEntity = $geoService->findNearestAddress($latitude, $longitude);

    if ($nearestEntity) {
        echo "Entidade mais próxima: " . $nearestEntity->relatedEntity->name;
    } else {
        echo "Nenhuma entidade encontrada próxima.";
    }
```

2. Utilizando a API de Geocodificação (Google) Se você configurou a chave da API do Google Maps, você também pode usar o serviço para obter as coordenadas de um endereço:

```
    use GeoLocationService\Services\GeoCodingAPI;

    $geoAPI = new GeoCodingAPI();
    $address = "São Paulo, Brasil";

    $coordinates = $geoAPI->getCoordinates($address);

    if ($coordinates) {
        echo "Latitude: " . $coordinates['lat'];
        echo "Longitude: " . $coordinates['lng'];
    } else {
        echo "Endereço não encontrado.";
}
```

Licença
-------

[](#licença)

Este projeto está sob a licença MIT.

[![MIT License](https://camo.githubusercontent.com/784362b26e4b3546254f1893e778ba64616e362bd6ac791991d2c9e880a3a64e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e2e737667)](https://camo.githubusercontent.com/784362b26e4b3546254f1893e778ba64616e362bd6ac791991d2c9e880a3a64e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e2e737667)

---

[![Laravel](https://camo.githubusercontent.com/5a580364ff3bd338370177402c5c050ff81a1933927e1e475c920c90850b38a3/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d4646324432303f7374796c653d666f722d7468652d6261646765266c6f676f3d6c61726176656c266c6f676f436f6c6f723d7768697465)](https://camo.githubusercontent.com/5a580364ff3bd338370177402c5c050ff81a1933927e1e475c920c90850b38a3/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d4646324432303f7374796c653d666f722d7468652d6261646765266c6f676f3d6c61726176656c266c6f676f436f6c6f723d7768697465) [![PHP](https://camo.githubusercontent.com/d282cc3193faee11ee32307d0c4c9d809e8fafa4b3a8c12c6afbf35d4f7ec617/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d3737374242343f7374796c653d666f722d7468652d6261646765266c6f676f3d706870266c6f676f436f6c6f723d7768697465)](https://camo.githubusercontent.com/d282cc3193faee11ee32307d0c4c9d809e8fafa4b3a8c12c6afbf35d4f7ec617/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d3737374242343f7374796c653d666f722d7468652d6261646765266c6f676f3d706870266c6f676f436f6c6f723d7768697465) [![Redis](https://camo.githubusercontent.com/54f47f4ba5351aef6dced8520ae1c67080cae212d1f1a2d4b629c220334e9907/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f72656469732d2532334444303033312e7376673f7374796c653d666f722d7468652d6261646765266c6f676f3d7265646973266c6f676f436f6c6f723d7768697465)](https://camo.githubusercontent.com/54f47f4ba5351aef6dced8520ae1c67080cae212d1f1a2d4b629c220334e9907/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f72656469732d2532334444303033312e7376673f7374796c653d666f722d7468652d6261646765266c6f676f3d7265646973266c6f676f436f6c6f723d7768697465)

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance46

Moderate activity, may be stable

Popularity2

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~0 days

Total

2

Last Release

413d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/19ca1d1760c3a17fe3753c0a2000ef158a7518ced94af1d4209c2d715ad17b59?d=identicon)[will-belo](/maintainers/will-belo)

---

Top Contributors

[![will-belo](https://avatars.githubusercontent.com/u/42493067?v=4)](https://github.com/will-belo "will-belo (7 commits)")

---

Tags

laravelgeolocationgoogle maps

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/will-belo-geo-location-service/health.svg)

```
[![Health](https://phpackages.com/badges/will-belo-geo-location-service/health.svg)](https://phpackages.com/packages/will-belo-geo-location-service)
```

###  Alternatives

[stevebauman/location

Retrieve a user's location by their IP Address

1.3k7.6M65](/packages/stevebauman-location)[torann/geoip

Support for multiple Geographical Location services.

2.2k14.2M76](/packages/torann-geoip)[adrianorosa/laravel-geolocation

Laravel Geo Location package to get details for a given IP Address

6593.3k1](/packages/adrianorosa-laravel-geolocation)[nativephp/mobile

NativePHP for Mobile

82724.0k43](/packages/nativephp-mobile)[bensampo/laravel-embed

Painless responsive embeds for videos, slideshows and more.

142146.8k](/packages/bensampo-laravel-embed)[glhd/conveyor-belt

14797.0k](/packages/glhd-conveyor-belt)

PHPackages © 2026

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