PHPackages                             gibilogic/element-geocoding - 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. gibilogic/element-geocoding

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

gibilogic/element-geocoding
===========================

GiBiLogic Elements - Geocoding

11661[2 PRs](https://github.com/gibilogic/element-geocoding/pulls)PHP

Since Mar 28Pushed 2y ago4 watchersCompare

[ Source](https://github.com/gibilogic/element-geocoding)[ Packagist](https://packagist.org/packages/gibilogic/element-geocoding)[ RSS](/packages/gibilogic-element-geocoding/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

GiBiLogic "Elements" library
============================

[](#gibilogic-elements-library)

Often we find ourselves writing the same code for different projects, over and over again.

We got bored, so we decided to collect all these bits and pieces of code in ready-to-use packages.

Geocoding Element
=================

[](#geocoding-element)

This package contains useful classes for working with geographical coordinates.

It uses Google's geocoding service; you can find more informations on its [official documentation](https://developers.google.com/maps/documentation/geocoding/start).

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

[](#installation)

Add this package to the `composer.json` of your application with the console command:

```
composer require gibilogic/element-geocoding
```

Or, if you are using the `composer.phar` version, use the console command:

```
php composer.phar require gibilogic/element-geocoding
```

Usage
-----

[](#usage)

### Basics

[](#basics)

Use the `Point` class to manage geographical points with latitude and longitude:

```
$milan = new Point(45.464161, 9.190336);
$rome = new Point(41.893056, 12.482778);
```

Use the `Route` class to manage relation between two points:

```
$route = new Route($milan, $rome);
$distance = $route->getDistance();
```

`Route` instances can also be compared by using the `compareTo` method:

```
$milanRomeRoute = new Route($milan, $rome);
$milanTurinRoute = new Route($milan, $turin);

$comparison = $milanRomeRoute->compareTo($milanTurinRoute);
```

Use the `geocodeAddress` method of the `GoogleGeocodeService` to get a `Point` instance from an address:

```
$point = $googleGeocodeService->geocodeAddress('via Aldo Moro 48, 25124 Brescia, Italy');
```

### Advanced

[](#advanced)

Add and implement the `GeocodeableInterface` to existing classes:

```
class Address implements GeocodeableInterface
{
    protected $address;
    protected $zipCode;
    protected $city;
    protected $province;

    protected $latitude;
    protected $longitude;

    // ...

    public function getAddressForGeocoding()
    {
        return sprintf('%s, %s %s (%s), Italy',
            $this->address,
            $this->zipCode,
            $this->city,
            $this->province
        );
    }

    public function getCoordinates()
    {
        return new Point($this->latitude, $this->longitude);
    }

    public function setCoordinates(Point $point)
    {
        $this->latitude = $point->getLatitude();
        $this->longitude = $point->getLongitude();
    }
}
```

Then use the `geocode` method of the `GoogleGeocodeService`:

```
$point = $googleGeocodeService->geocode($address);
```

Contributions
-------------

[](#contributions)

You can contribute to the growth of this library in a lot of different ways:

- Create an issue about a bug or a feature you would like to see implemented
- Open pull requests about fixes, new features, tests, documentation, etc.
- Use the library and let us know ;)

License
-------

[](#license)

See the attached [license](LICENSE) file.

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

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.

### Community

Maintainers

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

### Embed Badge

![Health badge](/badges/gibilogic-element-geocoding/health.svg)

```
[![Health](https://phpackages.com/badges/gibilogic-element-geocoding/health.svg)](https://phpackages.com/packages/gibilogic-element-geocoding)
```

###  Alternatives

[nativephp/electron

Electron wrapper for the NativePHP framework.

519114.4k8](/packages/nativephp-electron)[kadet/keylighter

Yet another syntax highlighter for PHP

333.2k1](/packages/kadet-keylighter)[code16/formoj

Customizable form renderer

332.6k](/packages/code16-formoj)[nullthoughts/laravel-data-sync

Laravel utility to keep records synced between environments through source control

331.4k](/packages/nullthoughts-laravel-data-sync)

PHPackages © 2026

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