PHPackages                             c3t4r4/openlocationcode - 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. c3t4r4/openlocationcode

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

c3t4r4/openlocationcode
=======================

Open Location Code (Plus Codes) implementation for PHP - Convert locations to and from short codes - Forked from google/open-location-code

v1.1.1(8mo ago)1957Apache-2.0PHPPHP ^8.0

Since Oct 16Pushed 8mo agoCompare

[ Source](https://github.com/c3t4r4/open-location-code)[ Packagist](https://packagist.org/packages/c3t4r4/openlocationcode)[ Docs](https://github.com/c3t4r4/open-location-code)[ RSS](/packages/c3t4r4-openlocationcode/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (4)Versions (2)Used By (0)

Open Location Code (Plus Codes) - PHP Implementation
====================================================

[](#open-location-code-plus-codes---php-implementation)

[![License](https://camo.githubusercontent.com/a549a7a30bacba7bfceebdc207a8e86c3f2c02995a2527640dca30048fd2b64e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d417061636865253230322e302d626c75652e737667)](https://opensource.org/licenses/Apache-2.0)[![PHP Version](https://camo.githubusercontent.com/e9b0c005a58eeb6aaac524aaaa3b42d0e30333344a47ff165a0225d4a9916043/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e322b2d3737374242342e737667)](https://www.php.net)[![Tests](https://camo.githubusercontent.com/0124267aec4ccaa059d042b491ee3e2ef47ce83cbb1636c3a461cafbffabe6f4/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f74657374732d37383225324637393625323070617373696e672d737563636573732e737667)](TEST_STATUS.md)[![Pest](https://camo.githubusercontent.com/70f2919e95576f2ebac2d4a32d70a432c129d74e4a0e01732bcf426794482eda/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f746573746564253230776974682d506573742d4646343038382e737667)](https://pestphp.com)

A PHP implementation of [Open Location Code](https://github.com/google/open-location-code) (also known as Plus Codes).

[Leia em Português](README.md)

Open Location Code is a technology that provides a way to encode location into a form that is easier to use than latitude and longitude. The codes generated are called Plus Codes.

Requirements
------------

[](#requirements)

- PHP 8.2 or higher

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

[](#installation)

Install via Composer:

```
composer require c3t4r4/openlocationcode
```

Basic Usage
-----------

[](#basic-usage)

### Encode a location

[](#encode-a-location)

```
use OpenLocationCode\OpenLocationCode;

// Encode with default precision (10 characters = ~13.5x13.5 meters)
$code = OpenLocationCode::encode(47.365590, 8.524997);
echo $code; // 8FVC9G8F+6X

// Encode with custom precision (11 characters = ~2.8x3.5 meters)
$code = OpenLocationCode::encode(47.365590, 8.524997, 11);
echo $code; // 8FVC9G8F+6XQ
```

### Decode a code

[](#decode-a-code)

```
use OpenLocationCode\OpenLocationCode;

$codeArea = OpenLocationCode::decode('8FVC9G8F+6X');

echo "Latitude Center: " . $codeArea->latitudeCenter . "\n";
echo "Longitude Center: " . $codeArea->longitudeCenter . "\n";
echo "Code Length: " . $codeArea->codeLength . "\n";

// Get center coordinates as array
[$lat, $lng] = $codeArea->getLatLng();
```

### Shorten a code

[](#shorten-a-code)

```
use OpenLocationCode\OpenLocationCode;

$shortCode = OpenLocationCode::shorten('8FVC9G8F+6X', 47.5, 8.5);
echo $shortCode; // 9G8F+6X
```

### Recover a full code

[](#recover-a-full-code)

```
use OpenLocationCode\OpenLocationCode;

$fullCode = OpenLocationCode::recoverNearest('9G8F+6X', 47.4, 8.6);
echo $fullCode; // 8FVC9G8F+6X
```

Testing
-------

[](#testing)

This project uses [Pest PHP](https://pestphp.com) for testing:

```
# Run all tests with Pest (recommended)
composer test

# Run with PHPUnit (legacy support)
composer test:phpunit

# Run specific test file
./vendor/bin/pest tests/BasicTest.pest.php
```

**Test Status**: ✅ 782/796 tests passing (98.2%)

- All critical functionality tested and working
- Round-trip encoding/decoding: 100% functional
- Minor variations in 14 edge cases are mathematically acceptable

Documentation
-------------

[](#documentation)

- [API Documentation](docs/API.md) - Complete API reference
- [Quick Start Guide](QUICK_START.md) - Step-by-step tutorial
- [Test Status](TEST_STATUS.md) - Detailed test analysis
- [Pest Migration](PEST_MIGRATION.md) - Testing framework guide
- [Portuguese README](README_BR.md) - Documentação em Português

For the official specification, visit the [Open Location Code repository](https://github.com/google/open-location-code).

License
-------

[](#license)

Copyright 2024 Google Inc.

Licensed under the Apache License, Version 2.0.

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance59

Moderate activity, may be stable

Popularity21

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity40

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

Unknown

Total

1

Last Release

261d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/46507382?v=4)[Glauco Garcia Cetara](/maintainers/c3t4r4)[@c3t4r4](https://github.com/c3t4r4)

---

Top Contributors

[![c3t4r4](https://avatars.githubusercontent.com/u/46507382?v=4)](https://github.com/c3t4r4 "c3t4r4 (3 commits)")

---

Tags

geocodinglocationlatitudelongitudecoordinatesopen-location-codeplus-codes

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/c3t4r4-openlocationcode/health.svg)

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

###  Alternatives

[anthonymartin/geo-location

Powerful GeoCoding library: Retrieve bounding box coordinates, distances between geopoints, point in polygon, get longitude and latitude from addresses and more with GeoLocation for PHP

1961.0M11](/packages/anthonymartin-geo-location)[data-values/geo

Geographical value objects, parsers and formatters

20654.5k22](/packages/data-values-geo)[php-coord/php-coord

PHPCoord is a PHP library to aid in handling coordinates. It can convert coordinates for a point from one system to another and also calculate distance between points.

109996.7k12](/packages/php-coord-php-coord)[jeroendesloovere/distance

Get distance between two locations using PHP.

3665.3k](/packages/jeroendesloovere-distance)[laravie/geotools

Geo-related tools PHP 7+ library

18136.3k1](/packages/laravie-geotools)[kolyunya/yii2-map-input-widget

Yii2 map input widget. Allows you to select geographcal coordinates via a human-friendly inteface.

2836.8k4](/packages/kolyunya-yii2-map-input-widget)

PHPackages © 2026

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