dan-har / google-maps-services-php
Google maps web services php client.
Installs: 57
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/dan-har/google-maps-services-php
Requires
- php: >=5.5.9
- guzzlehttp/guzzle: ^6.3
Requires (Dev)
- mockery/mockery: ^0.9.7
- phpunit/phpunit: 4.8.*
This package is not auto-updated.
Last update: 2025-10-02 19:03:25 UTC
README
PHP client for google maps api service.
Installation
Install using composer
composer require dan-har/google-maps-services-php
Usage
$placesService = new PlacesApi(new Client(), Auth::fromKey('GOOGLE_API_KEY')); $placeId = 'ChIJN1t_tDeuEmsRUsoyG83frY4'; try { $placeResponse = $placesService->details($placeId); } catch (ResourceRequestException $e) { // handle request exception, for example caused by timeout } // check if the response is ok, if so we have a result for the place id if( ! $placeResponse->isOk()) { // handle request failure, for example no results, wrong place id etc. } $result = $placeResponse->result(); // check for address component foreach($result->addressComponents as $addressComponent) { if($addressComponent->isType(AddressType::LOCALITY)) { // } } // get the geometry object. $geometry = $result->geometry;