PHPackages                             thorazine/location - 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. thorazine/location

ActiveLibrary

thorazine/location
==================

A location reverser for Laravel with Google API

3.1.1(5y ago)1457[2 PRs](https://github.com/Thorazine/location/pulls)MITPHP

Since Jul 21Pushed 6mo agoCompare

[ Source](https://github.com/Thorazine/location)[ Packagist](https://packagist.org/packages/thorazine/location)[ RSS](/packages/thorazine-location/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (10)Dependencies (2)Versions (19)Used By (0)

[![Total Downloads](https://camo.githubusercontent.com/fe51294d0f22e42303c33686034e32392aeb16e84adb431372654cac5076a734/68747470733a2f2f706f7365722e707567782e6f72672f74686f72617a696e652f6c6f636174696f6e2f642f746f74616c2e737667)](https://packagist.org/packages/thorazine/location)[![Latest Stable Version](https://camo.githubusercontent.com/64fc99fb1f0a22a4656793631e05fd99b74db8af94433a20d599e027be189440/68747470733a2f2f706f7365722e707567782e6f72672f74686f72617a696e652f6c6f636174696f6e2f762f737461626c652e737667)](https://packagist.org/packages/thorazine/location)[![License](https://camo.githubusercontent.com/9203b8ea08e5ec78c2e175dacd8feb5c0d3524c0c449186e8ec1211afd1e909b/68747470733a2f2f706f7365722e707567782e6f72672f74686f72617a696e652f6c6f636174696f6e2f6c6963656e73652e737667)](https://packagist.org/packages/thorazine/location)

Geo data to Geolocation
=======================

[](#geo-data-to-geolocation)

Get a complete standardized location php array or object from coordinates, address, postal code or IP. Through the Location Facade you can request the Google and IpInfo API to return the address of a visitor on your website. This script works out of the box, no need for any keys or registrations.

What you should keep in mind
----------------------------

[](#what-you-should-keep-in-mind)

This script uses the Google geodata and maps API to request information. Especially with the IP API there is margin for error. The Google API is quite accurate. However, please don't use this data as fact but rather as indication.

How to make it work
-------------------

[](#how-to-make-it-work)

Run:

```
composer require thorazine/location

```

That's it

If you are on Laravel &lt; 5.5
------------------------------

[](#if-you-are-on-laravel--55)

You can't use this version. Please go to the [pre55 branch](https://github.com/Thorazine/location/tree/pre55)

Other optional stuff
--------------------

[](#other-optional-stuff)

Get the configuration:

```
php artisan vendor:publish --tag=location

```

If you have a Google key add a line to your .env file:

```
GOOGLE_KEY=[key]

```

> This script used to work out of the box without a key, but it doesn't anymore. Thanks Google. You can request one [here](https://developers.google.com/maps/documentation/geocoding/get-api-key)Do make sure it has sufficiant rights.

These (quick examples):

```
$location = Location::locale('nl')->coordinatesToAddress(['latitude' => 52.385288, 'longitude' => 4.885361])->get();

$location = Location::locale('nl')->addressToCoordinates(['country' => 'Nederland', 'street' => 'Nieuwe Teertuinen', 'street_number' => 25])->get();

$location = Location::locale('nl')->postalcodeToCoordinates(['postal_code' => '1013 LV', 'street_number' => '25'])->coordinatesToAddress()->get();

$location = Location::locale('nl')->postalcodeToCoordinates(['postal_code' => '1013 LV', 'street_number' => '25'], true)->get();

$location = Location::locale('nl')->ipToCoordinates('46.44.160.221')->coordinatesToAddress()->get(); // if IP resolves properly, which it mostly doesn't

$location = Location::locale('nl')->ipToCoordinates('46.44.160.221', true)->get(); // if IP resolves properly, which it mostly doesn't
```

Will all result in:

```
$location['latitude'] = 52.385288,
$location['longitude'] = 4.885361;
$location['iso'] = 'NL';
$location['country'] = 'Nederland';
$location['region'] = 'Noord-Holland';
$location['city'] = 'Amsterdam';
$location['street'] = 'Nieuwe Teertuinen';
$location['street_number'] = '25';
$location['postal_code'] = '1013 LV';
```

To return it as object set the `get()` function to true: `get(true)`

Limit results by country
------------------------

[](#limit-results-by-country)

To limit the search results to only be included when from a set of predefined countries, use the `countries()` function. It accepts iso notation country names as defined by "ISO 3166-1 alpha-2".

Extended example:
-----------------

[](#extended-example)

```
try {
	$location = Location::coordinatesToAddress(['latitude' => 52.385288, 'longitude' => 4.885361])->get(true);

	if($error = Location::error()) {
		dd($error);
	}
}
catch(Exception $e) {
	dd($e->getMessage());
}
```

The result is the default template and starts out as empty and gets filled throughout the call. So if no data is available the result for that entry will be "". After every call the script resets to it's initial template.

Chainable functions and their variables
---------------------------------------

[](#chainable-functions-and-their-variables)

FunctionsValuesValidationTypecountries()iso'srequiredarraycoordinatesToAddress()latituderequiredfloatlongituderequiredfloataddressToCoordinates()countryrecommendedstringregionstringcityrequiredstringstreetrecommendedstringstreet\_numberrecommendedstringpostalcodeToCoordinates()postal\_coderequiredstringstreet\_numberrecommendedstringget()true/falsebooleanbooleanOther functions
---------------

[](#other-functions)

FunctionsValuesResulterror()noneReturns any error if there is oneresponse()noneReturns the raw response from the Google APIDebug
-----

[](#debug)

With the try catch you can already see what you need. But besides this there is also a cached result of the raw response from the google API. Please note that this is not the case with the ip request.

```
$location = Location::coordinatesToAddress(['latitude' => 52.385288, 'longitude' => 4.885361])->get();
Location::response(); // results in raw api response
```

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance47

Moderate activity, may be stable

Popularity14

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity72

Established project with proven stability

 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 ~74 days

Recently: every ~239 days

Total

15

Last Release

2180d ago

Major Versions

0.0.1 → 1.0.02017-07-21

1.0.8 → 2.0.02017-10-05

1.0.9 → 3.0.02019-02-26

### Community

Maintainers

![](https://www.gravatar.com/avatar/530648da75b2b5d21c320856ebf7a1c4c134cc8088d16bf55d13cddc9f62a00b?d=identicon)[Thorazine](/maintainers/Thorazine)

---

Top Contributors

[![Thorazine](https://avatars.githubusercontent.com/u/2406201?v=4)](https://github.com/Thorazine "Thorazine (15 commits)")

### Embed Badge

![Health badge](/badges/thorazine-location/health.svg)

```
[![Health](https://phpackages.com/badges/thorazine-location/health.svg)](https://phpackages.com/packages/thorazine-location)
```

###  Alternatives

[neuron-core/neuron-ai

The PHP Agentic Framework.

1.8k245.3k21](/packages/neuron-core-neuron-ai)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3731.2M42](/packages/tencentcloud-tencentcloud-sdk-php)[vormkracht10/laravel-mails

Laravel Mails can collect everything you might want to track about the mails that has been sent by your Laravel app.

24149.7k](/packages/vormkracht10-laravel-mails)[concrete5/core

Concrete core subtree split

19159.3k48](/packages/concrete5-core)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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