PHPackages                             clevyr/laravel-geocoder - 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. clevyr/laravel-geocoder

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

clevyr/laravel-geocoder
=======================

Handles geocoding an address into lat/lng with multiple providers

v0.1.1(3y ago)0611[3 PRs](https://github.com/clevyr/laravel-geocoder/pulls)MITPHPPHP ^8.1

Since Jun 24Pushed 2y ago3 watchersCompare

[ Source](https://github.com/clevyr/laravel-geocoder)[ Packagist](https://packagist.org/packages/clevyr/laravel-geocoder)[ Docs](https://github.com/clevyr/laravel-geocoder)[ RSS](/packages/clevyr-laravel-geocoder/feed)WikiDiscussions main Synced 4w ago

READMEChangelogDependencies (13)Versions (7)Used By (0)

Laravel Geocoder
================

[](#laravel-geocoder)

[![Latest Version on Packagist](https://camo.githubusercontent.com/b033d7ae32e116b21fea3e5d14c9008a716175194189a501a80b2603a909c26c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f636c657679722f6c61726176656c2d67656f636f6465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/clevyr/laravel-geocoder)[![GitHub Tests Action Status](https://camo.githubusercontent.com/8de74dc1f8cb5ae051fb91d5decf6a103133a00a732b8059c97828915662d536/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f636c657679722f6c61726176656c2d67656f636f6465722f72756e2d74657374733f6c6162656c3d7465737473)](https://github.com/clevyr/laravel-geocoder/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/47dd5d793236399a647dddae09a488f9d415a2e521b02154a5df17c1283676f1/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f636c657679722f6c61726176656c2d67656f636f6465722f436865636b253230262532306669782532307374796c696e673f6c6162656c3d636f64652532307374796c65)](https://github.com/clevyr/laravel-geocoder/actions?query=workflow%3A%22Check+%26+fix+styling%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/1b206f77ecd430bbcf7d7b029817f5c003e3472890d8b30e9d26825b309b17a2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f636c657679722f6c61726176656c2d67656f636f6465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/clevyr/laravel-geocoder)

Handles geocoding an address into lat/lng based on cloud providers.

**Note:** Currently only supports using **Google** as a Geocoding provider. As we prioritize it, we will implement MapBox as well.

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

[](#installation)

You can install the package via composer:

```
composer require clevyr/laravel-geocoder
```

Next, publish the plugin assets:

```
php artisan vendor:publish --provider="Clevyr\LaravelGeocoder\LaravelGeocoderServiceProvider"
```

This is the contents of the published config file (without descriptive comments):

```
return [
    'adapter' => 'google',
    'test-adapter' => 'test',
    'test' => [
        'lat' => 35.4771302,
        'lng' => -97.5283204,
    ],
];
```

Set up Google Geocoding
-----------------------

[](#set-up-google-geocoding)

First, you need to [set up a Google Geocoding API Key](https://developers.google.com/maps/documentation/geocoding/get-api-key#creating-api-keys)

Then, you will need to set the following ENV variable in your Laravel application:

```
GOOGLE_CLOUD_API_KEY=

```

Usage
-----

[](#usage)

```
use Clevyr\LaravelGeocoder\LaravelGeocoder;

$coords = LaravelGeocoder::GetLatLngFromAddress(
    '123 Test Ln',
    null,
    'New York',
    'NY',
    '10001',
);

echo $coords;

// [
//     "lat" => 40.7607184,
//     "lng" => -73.9613766,
// ]
```

Alternatively, you can include the `Geocodable` trait in your Laravel Eloquent model to get some nice geocoding instance methods:

```
use Clevyr\LaravelGeocoder\Traits\Geocodable;

class MyModel extends Model
{
    use Geocodable;
}

$model = MyModel::find(1);
$coords = $model->getLatAndLong();

$model->name = 'New Name';
$model->addressIsDirty(); // false

$model->address_line_1 = '123 Foo Ln.';
$model->addressIsDirty(); // true
```

### Modifying the Model Geolocation Fields

[](#modifying-the-model-geolocation-fields)

By default, when you use the `Geocodable` trait, Laravel Geocoder will default to using the following fields on your model:

- `address_line_1` (Required)
- `address_line_2`
- `city` (Required)
- `state` (Required)
- `postal_code` (Required)
- `country` (Defaults to 'US')

However, you can modify these fields on a per-model basis using the following getter functions in your model:

```
    // Override the postal_code property with something specific to this model
    public function getGeocoderPostalCodeAttribute()
    {
        return 'zip';
    }
```

This would assume that there is a `zip` field on this model, which will then be used for this model's geolocation. Here are the full list of getter functions that you can override:

```
public function getGeocoderAddressLine1Attribute();
public function getGeocoderAddressLine2Attribute();
public function getGeocoderCityAttribute();
public function getGeocoderStateAttribute();
public function getGeocoderPostalCodeAttribute();
public function getGeocoderCountryAttribute();
```

Testing
-------

[](#testing)

```
composer test
```

Linting
-------

[](#linting)

```
composer analyse
```

[Laravel Pint](https://laravel.com/docs/9.x/pint)
-------------------------------------------------

[](#laravel-pint)

Laravel Pint is an opinionated PHP code style fixer for minimalists.

```
./vendor/bin/pint
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Aaron Krauss](https://github.com/thecodeboss)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 62.2% 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 ~59 days

Total

2

Last Release

1355d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/826043?v=4)[Clevyr](/maintainers/clevyr)[@clevyr](https://github.com/clevyr)

---

Top Contributors

[![alkrauss48](https://avatars.githubusercontent.com/u/1478883?v=4)](https://github.com/alkrauss48 "alkrauss48 (23 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (7 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (7 commits)")

---

Tags

laravelClevyrlaravel-geocoder

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/clevyr-laravel-geocoder/health.svg)

```
[![Health](https://phpackages.com/badges/clevyr-laravel-geocoder/health.svg)](https://phpackages.com/packages/clevyr-laravel-geocoder)
```

###  Alternatives

[spatie/laravel-data

Create unified resources and data transfer objects

1.7k28.9M626](/packages/spatie-laravel-data)[spatie/laravel-livewire-wizard

Build wizards using Livewire

4061.0M4](/packages/spatie-laravel-livewire-wizard)[hirethunk/verbs

An event sourcing package that feels nice.

513162.9k6](/packages/hirethunk-verbs)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

123544.7k](/packages/worksome-exchange)[ralphjsmit/livewire-urls

Get the previous and current url in Livewire.

82270.3k4](/packages/ralphjsmit-livewire-urls)[hydrat/filament-table-layout-toggle

Filament plugin adding a toggle button to tables, allowing user to switch between Grid and Table layouts.

6292.3k1](/packages/hydrat-filament-table-layout-toggle)

PHPackages © 2026

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