PHPackages                             chroma-x/google-datastructures - 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. chroma-x/google-datastructures

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

chroma-x/google-datastructures
==============================

A PHP library providing common data structures to reflect data received from Google services.

2.0.2(5y ago)017.5k↓40%12MITPHPPHP &gt;=5.3

Since Apr 25Pushed 5y ago1 watchersCompare

[ Source](https://github.com/chroma-x/php-google-datastructures)[ Packagist](https://packagist.org/packages/chroma-x/google-datastructures)[ Docs](http://chroma-x.de/)[ RSS](/packages/chroma-x-google-datastructures/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (8)DependenciesVersions (9)Used By (2)

PHP Google Data Structures
==========================

[](#php-google-data-structures)

[![SensioLabs Insight](https://camo.githubusercontent.com/24325391be087276e86efea6c760e09e58179afa6eb9580629738cc3b61493c8/68747470733a2f2f696d672e736869656c64732e696f2f73656e73696f6c6162732f692f61633664353864612d613839662d343738352d623563362d6436373637636537663863612e737667)](https://insight.sensiolabs.com/projects/ac6d58da-a89f-4785-b5c6-d6767ce7f8ca)[![Code Climate](https://camo.githubusercontent.com/8600da548d25f42ccb255fdf1ebf572aae203a4166f46fb9b68d659f05328996/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f6368726f6d612d782f7068702d676f6f676c652d64617461737472756374757265732f6261646765732f6770612e737667)](https://codeclimate.com/github/chroma-x/php-google-datastructures)[![Latest Stable Version](https://camo.githubusercontent.com/b639b8441f681f74050f75ffcf5dbc2156e6a45e1d3178595fc1da5383b0afc7/68747470733a2f2f706f7365722e707567782e6f72672f6368726f6d612d782f676f6f676c652d64617461737472756374757265732f762f737461626c65)](https://packagist.org/packages/chroma-x/google-datastructures)[![Total Downloads](https://camo.githubusercontent.com/a5841b6bcc4240dda64a011e95c8043495f238cb00fca9d71e05d9379a612091/68747470733a2f2f706f7365722e707567782e6f72672f6368726f6d612d782f676f6f676c652d64617461737472756374757265732f646f776e6c6f616473)](https://packagist.org/packages/chroma-x/google-datastructures)[![License](https://camo.githubusercontent.com/c77fac92f0f05580c4b0156b791aa8f236b4f93c6836a2fc2e9dc3c241ab57c9/68747470733a2f2f706f7365722e707567782e6f72672f6368726f6d612d782f676f6f676c652d64617461737472756374757265732f6c6963656e7365)](https://packagist.org/packages/chroma-x/google-datastructures)

A PHP library to query Google's Places service for querying locations and addresses and getting details by Places ID.

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

[](#installation)

```
{
   	"require": {
        "chroma-x/google-datastructures": "*"
    }
}

```

Usage
-----

[](#usage)

### Autoloading and namesapce

[](#autoloading-and-namesapce)

```
require_once('path/to/vendor/autoload.php');

```

---

GeoLocation data structures
---------------------------

[](#geolocation-data-structures)

### Reading a Google Places or Google Geocoder result

[](#reading-a-google-places-or-google-geocoder-result)

See [PHP Google Places Suite](https://github.com/chroma-x/php-google-places-suite) or [PHP Google Geocoder](https://github.com/chroma-x/php-google-geocoder) for example libraries using these datastructures.

**Attention:** Plaese note that all getter methods on the `GeoLocationAddress` return a `GeoLocationAddressComponent` instance or `null`. For preventing calls on non-objects the `GeoLocationAddress` class provides methods to check whether the address components exists.

```
// Retrieving a query result as ChromaX\GooglePlacesSuite\GooglePlacesDetailResult instance
$googlePlacesDetailQuery = new GooglePlacesDetailQuery();
$googlePlacesDetailQuery
	->setApiKey($this->googlePlacesApiKey)
	->query('GOOGLE_PLACES_ID');
$queryResult = $googlePlacesDetailQuery->getResult();

// Retieving address information as ChromaX\GoogleDataStructure\GeoLocation\GeoLocationAddress
if($queryResult->hasAddress()) {

	if ($queryResult->getAddress()->hasStreetName()) {
		// Returns 'Lornsenstraße'
		$addressStreetShort = $queryResult->getAddress()->getStreetName()->getShortName();
		// Returns 'Lornsenstraße'
		$addressStreetLong = $queryResult->getAddress()->getStreetName()->getLongName();
	}

	if ($queryResult->getAddress()->hasStreetNumber()) {
		// Returns '43'
		$addressStreetNumberShort = $queryResult->getAddress()->getStreetNumber()->getShortName();
		// Returns '43'
		$addressStreetNumberLong = $queryResult->getAddress()->getStreetNumber()->getLongName();
	}

	if ($queryResult->getAddress()->hasPostalCode()) {
		// Returns '24105'
		$addressPostalCodeShort = $queryResult->getAddress()->getPostalCode()->getShortName();
		// Returns '24105'
		$addressPostalCodeLong = $queryResult->getAddress()->getPostalCode()->getLongName();
	}

	if ($queryResult->getAddress()->hasCity()) {
		// Returns 'KI'
		$addressCityShort = $queryResult->getAddress()->getCity()->getShortName();
		// Returns 'Kiel'
		$addressCityLong = $queryResult->getAddress()->getCity()->getLongName();
	}

	if ($queryResult->getAddress()->hasArea()) {
		// Returns 'Ravensberg - Brunswik - Düsternbrook'
		$addressAreaShort = $queryResult->getAddress()->getArea()->getShortName();
		// Returns 'Ravensberg - Brunswik - Düsternbrook'
		$addressAreaLong = $queryResult->getAddress()->getArea()->getLongName();
	}

	if ($queryResult->getAddress()->hasProvince()) {
		// Returns 'SH'
		$addressProvinceShort = $queryResult->getAddress()->getProvince()->getShortName();
		// Returns 'Schleswig-Holstein'
		$addressProvinceLong = $queryResult->getAddress()->getProvince()->getLongName();
	}

	if ($queryResult->getAddress()->hasCountry()) {
		// Returns 'DE'
		$addressCountryShort = $queryResult->getAddress()->getCountry()->getShortName();
		// Returns 'Germany'
		$addressCountryLong = $queryResult->getAddress()->getCountry()->getLongName();
	}

}

// Retieving address information as ChromaX\GoogleDataStructure\GeoLocation\GeoLocationGeometry
if ($queryResult->hasGeometry()) {

	if ($queryResult->getGeometry()->hasLocation()) {
		// Returns 54.334123
		$geometryLocationLatitude = $queryResult->getGeometry()->getLocation()->getLatitude();
		// Returns 10.1364007
		$geometryLocationLatitude = $queryResult->getGeometry()->getLocation()->getLongitude();
	}

	if ($queryResult->getGeometry()->hasViewport()) {
		// Returns 54.335471980291
		$geometryLocationLatitude = $queryResult->getGeometry()->getViewport()->getNortheast()->getLatitude();
		// Returns 10.137749680292
		$geometryLocationLatitude = $queryResult->getGeometry()->getViewport()->getNortheast()->getLongitude();
		// Returns 54.332774019708
		$geometryLocationLatitude = $queryResult->getGeometry()->getViewport()->getSouthwest()->getLatitude();
		// Returns 10.135051719708
		$geometryLocationLatitude = $queryResult->getGeometry()->getViewport()->getSouthwest()->getLongitude();
	}

	if ($queryResult->getGeometry()->hasAccessPoints()) {
		for ($i = 0; $i < $queryResult->getGeometry()->countAccessPoints(); $i++) {
			// Returns 54.335471980291
			$geometryAccessPointLatitude = $queryResult->getGeometry()->getAccessPointAt($i)->getLatitude();
			// Returns 10.137749680292
			$geometryAccessPointLatitude = $queryResult->getGeometry()->getAccessPointAt($i)->getLongitude();
		}
	}

}

if ($queryResult->hasGooglePlacesId()) {
	// Retrieving the Google Places information from the query result
	// Returns 'ChIJ_zNzWmpWskcRP8DWT5eX5jQ'
	$googlePlacesId = $queryResult->getGooglePlacesId();
}

```

Contribution
------------

[](#contribution)

Contributing to our projects is always very appreciated.
**But: please follow the contribution guidelines written down in the [CONTRIBUTING.md](https://github.com/chroma-x/php-google-datastructures/blob/master/CONTRIBUTING.md) document.**

License
-------

[](#license)

PHP Google Places Suite is under the MIT license.

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity63

Established project with proven stability

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

Recently: every ~432 days

Total

8

Last Release

1946d ago

Major Versions

0.1.2 → 1.02016-04-25

1.0.1 → 2.0.02016-07-11

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5921241?v=4)[Martin Brecht-Precht](/maintainers/bonscho)[@Bonscho](https://github.com/Bonscho)

---

Tags

commoncomposer-packagedatastructuresgooglephp-librarygoogledata structure

### Embed Badge

![Health badge](/badges/chroma-x-google-datastructures/health.svg)

```
[![Health](https://phpackages.com/badges/chroma-x-google-datastructures/health.svg)](https://phpackages.com/packages/chroma-x-google-datastructures)
```

###  Alternatives

[spatie/laravel-analytics

A Laravel package to retrieve Google Analytics data.

3.2k5.7M57](/packages/spatie-laravel-analytics)[spatie/laravel-google-calendar

Manage events on a Google Calendar

1.4k1.5M21](/packages/spatie-laravel-google-calendar)[cornford/googlmapper

An easy way to integrate Google Maps with Laravel.

457447.9k4](/packages/cornford-googlmapper)[emcconville/google-map-polyline-encoding-tool

A simple class to handle polyline-encoding for Google Maps

1572.3M2](/packages/emcconville-google-map-polyline-encoding-tool)[kreait/gcp-metadata

Get the metadata from a Google Cloud Platform environment.

664.8M1](/packages/kreait-gcp-metadata)[loophp/phptree

An implementation of tree data structure

981.8M2](/packages/loophp-phptree)

PHPackages © 2026

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