PHPackages                             alex-kalanis/google-maps-php-services - 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. [API Development](/categories/api)
4. /
5. alex-kalanis/google-maps-php-services

ActiveLibrary[API Development](/categories/api)

alex-kalanis/google-maps-php-services
=====================================

PHP client library(SDK) for Google Maps API Web Services

v10.1.1(2mo ago)013↓75%MITPHPPHP &gt;=8.1CI passing

Since Aug 4Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/alex-kalanis/google-maps-php-services)[ Packagist](https://packagist.org/packages/alex-kalanis/google-maps-php-services)[ Docs](https://github.com/alex-kalanis/google-maps-php-services)[ RSS](/packages/alex-kalanis-google-maps-php-services/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (7)Versions (4)Used By (0)

 [ ![](https://camo.githubusercontent.com/b0fad14cc895cce0fdd6f80d40f2849a6e27e02408d13a8c92368b52175d544f/68747470733a2f2f636c6f75642e676f6f676c652e636f6d2f696d616765732f6d6170732d706c6174666f726d2f676f6f676c652d6d6170732d6c6f636b75702e737667) ](https://cloud.google.com/maps-platform/)

Google Maps Services *for* PHP
==============================

[](#google-maps-services-for-php)

PHP client library(SDK) for Google Maps API Web Services.

Fork of older Nick Tsai's library.

[![Build Status](https://github.com/alex-kalanis/google-maps-php-services/actions/workflows/code_checks.yml/badge.svg)](https://github.com/alex-kalanis/google-maps-php-services/actions/workflows/code_checks.yml/badge.svg)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/9b6f8319a8d8a4ac85ed5ff1fed66302f32ad0cbf96359a1d08ee794acbb4948/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f616c65782d6b616c616e69732f676f6f676c652d6d6170732d7068702d73657276696365732f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/alex-kalanis/google-maps-php-services/?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/1fce490bcc4646dd77fa47233c8f4606edfa69388c276a53591f3eb477d242d3/68747470733a2f2f706f7365722e707567782e6f72672f616c65782d6b616c616e69732f676f6f676c652d6d6170732d7068702d73657276696365732f762f737461626c652e7376673f763d31)](https://packagist.org/packages/alex-kalanis/google-maps-php-services)[![Minimum PHP Version](https://camo.githubusercontent.com/183804d09fec16ca7b6209b007250b7d8db1b915042feb093a9f20e6e1f25359/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344253230382e312d3838393242462e737667)](https://php.net/)[![Downloads](https://camo.githubusercontent.com/5a669cc4a52b38e201df2694b0e20659931ec52bd435e1cd873215ce038bad94/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f616c65782d6b616c616e69732f676f6f676c652d6d6170732d7068702d73657276696365732e7376673f7631)](https://packagist.org/packages/alex-kalanis/google-maps-php-services)[![License](https://camo.githubusercontent.com/7ee7992e09a18351cc7f137295d5edbb71b1895c1477245f642c5e7fe27c049e/68747470733a2f2f706f7365722e707567782e6f72672f616c65782d6b616c616e69732f676f6f676c652d6d6170732d7068702d73657276696365732f6c6963656e73652e7376673f763d31)](https://packagist.org/packages/alex-kalanis/google-maps-php-services)[![Code Coverage](https://camo.githubusercontent.com/30b15ddd03d8d53be201af245d10dfb69e9f0a65c3e0569faf80817b8d0b94d2/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f616c65782d6b616c616e69732f676f6f676c652d6d6170732d7068702d73657276696365732f6261646765732f636f7665726167652e706e673f623d6d617374657226763d31)](https://scrutinizer-ci.com/g/alex-kalanis/google-maps-php-services/?branch=master)

### Differences:

[](#differences)

- Minimal php is 8.1
- Type checks
- Dependency injection
- With PSR and other remote libraries than Guzzle/Curl in mind
- Only API key now usable

OUTLINE
-------

[](#outline)

- [Demonstration](#demonstration)
- [Description](#description)
- [Requirements](#requirements)
    - [API keys](#api-keys)
- [Installation](#installation)
- [Usage](#usage)
    - [Client](#client)
        - [Language](#language)
    - [Directions API](#directions-api)
    - [Distance Matrix API](#distance-matrix-api)
    - [Routes API](#routes-api)
    - [Elevation API](#elevation-api)
    - [Geocoding API](#geocoding-api)
    - [Geolocation API](#geolocation-api)
    - [Time Zone API](#time-zone-api)
    - [Nearby API](#nearby-api)
    - [Find by Place API](#find-by-place-api)
    - [Find by Text API](#find-by-text-api)
    - [Place details API](#place-details-api)

---

DEMONSTRATION
-------------

[](#demonstration)

For nearly any raw php / custom frameworks:

```
// somewhere in configuration something like this

/// ... with anonymous function as setter in DI
function (): \kalanis\google_maps\ClientConfig
{
    return \kalanis\google_maps\ClientConfig::init('Your API Key');
}
```

Then on desired pages:

```
class YourPresenter extends YourFramework
{
    public function __construct(
        // ... other used classes
        protected readonly kalanis\google_maps\Client $mapService,
    ) {
    }

    public function process(): void
    {
        // Geocoding an address
        $geocodeResult = $this->mapService->geocode('Pelješki most, Croatia');

        // Look up an address with reverse geocoding
        $reverseGeocodeResult = $this->mapService->reverseGeocode(42.916667, 17.533333);

        // Request directions via public transit
        $directionsResult = $this->mapService->directions('Ploče', 'Dubrovnik', [
            'mode' => "transit",
            'departure_time' => time(),
        ]);
    }
}
```

For [Laravel](https://laravel.com/):

```
/// app\Providers\AppServiceProvider.php
public function register()
{
    // ... other binds
    $this->app->bind(\kalanis\google_maps\Client::class, function(
            \Psr\Http\Client\ClientInterface $client,
            \Psr\Http\Message\RequestInterface $request,
        ): \kalanis\google_maps\Client {
            return new \kalanis\google_maps\Client(
                $request,
                $client,
                \kalanis\google_maps\ClientConfig::init('Your API Key'),
            );
        }
    );
}
```

And then in the controller is the code the same as in another random framework.

For [Symfony](https://symfony.com/):

```
# config/services.yaml
services:
  kalanis\google_maps\ClientConfig:
    arguments: ['Your API Key']
  kalanis\google_maps\Client:
    arguments: ['@Psr\Http\Message\RequestInterface', '@Psr\Http\Client\ClientInterface', '@kalanis\google_maps\ClientConfig']
```

```
namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;

#[Route('/your-maps')]
class YourMapsPresenter extends AbstractController
{
    public function __construct(
        // ... other used classes
        protected readonly kalanis\google_maps\Client $mapService,
    ) {
    }

    #[Route('/geocode', name: 'maps_geocode', defaults: ['where' => 'Pelješki most, Croatia'], methods: ['GET'])]
    public function geocode(Request $request, string $where): Response
    {
        $geocodeResult = $this->mapService->geocode($where);
        return new JsonResponse($geocodeResult)
    }

    #[Route('/reverse-geocode', lat: '42.916667', lon: '17.533333', defaults: ['lat' => '42.916667', 'lon' => '17.533333'], methods: ['GET'])]
    public function reverseGeocode(Request $request, string $lat, string $lon): Response
    {
        $geocodeResult = $this->mapService->reverseGeocode([$lat, $lon]);
        return new JsonResponse($geocodeResult)
    }
}
```

For [Nette](https://nette.org/):

```
services:
    # ... other ones
    - kalanis\google_maps\ClientConfig('Your API Key')
    - kalanis\google_maps\Client
    # ... other ones
```

Or with parameters for different servers/services:

```
parameters:
    # ... other ones
    googleMapsKey: 'Your API Key'
    # ... other ones

services:
    # ... other ones
    - kalanis\google_maps\ClientConfig(%parameters.googleMapsKey%)
    - kalanis\google_maps\Client
    # ... other ones
```

And then in class like in other frameworks with DI.

---

DESCRIPTION
-----------

[](#description)

The PHP Client for Google Maps Services is a PHP Client library for the following [Google Maps APIs](https://developers.google.com/maps):

- Maps
    - [Elevation API](#elevation-api) ([Google Doc](https://developers.google.com/maps/documentation/elevation/))
- Routes
    - [Routes API](#routes-api) ([Google Doc](https://developers.google.com/maps/documentation/routes))
    - [Roads API](#roads-api) ([Google Doc](https://developers.google.com/maps/documentation/roads))
    - [Directions API](#directions-api) ([Google Doc](https://developers.google.com/maps/documentation/directions/))
    - [Distance Matrix API](#distance-matrix-api) ([Google Doc](https://developers.google.com/maps/documentation/distancematrix/))
- Places
    - [Geocoding API](#geocoding-api) ([Google Doc](https://developers.google.com/maps/documentation/geocoding/))
    - [Geolocation API](#geolocation-api) ([Google Doc](https://developers.google.com/maps/documentation/geolocation/))
    - [Time Zone API](#time-zone-api) ([Google Doc](https://developers.google.com/maps/documentation/timezone/))
    - [Nearby API](#nearby-api) ([Google Doc](https://developers.google.com/maps/documentation/places/web-service/search-nearby/))
    - [Find by Place API](#find-by-place-api) ([Google Doc](https://developers.google.com/maps/documentation/places/web-service/search-find-place))
    - [Find by Text API](#find-by-text-api) ([Google Doc](https://developers.google.com/maps/documentation/places/web-service/search-text))
    - [Place details API](#place-details-api) ([Google Doc](https://developers.google.com/maps/documentation/places/web-service/details))

---

REQUIREMENTS
------------

[](#requirements)

- PHP 8.1+ or higher

### API keys

[](#api-keys)

Each Google Maps Web Service request requires an API key or client ID. API keys are freely available with a Google Account at . The type of API key you need is a **Server key**.

To get an API key:

1. Visit  and log in with a Google Account.
2. Select one of your existing projects, or create a new project.
3. Enable the Google Maps Services API(s) you plan to use, such as:

    - Directions API
    - Distance Matrix API
    - Geocoding API
    - Places API
    - Roads API
    - Time Zone API
    - Nearby API
4. Create a new **Server key**.
5. If you'd like to restrict requests to a specific IP address, do so now.

For guided help, follow the instructions for the [Directions API](https://developers.google.com/maps/documentation/directions/get-api-key#key). You only need one API key, but remember to enable all the APIs you need. For even more information, see the guide to [API keys](https://developers.google.com/maps/documentation/directions/get-api-key#before-you-begin).

**Important:** This key should be kept secret on your server.

---

INSTALLATION
------------

[](#installation)

Run Composer in your project:

```
composer require alex-kalanis/google-maps-php-services

```

Then you could call it after Composer is loaded depended on your PHP framework:

```
require __DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';

use kalanis\google_maps\Client;
```

---

USAGE
-----

[](#usage)

Before using any Google Maps Services, first you need to create a Client with configuration, then use the client to access Google Maps Services.

### Client

[](#client)

Create a Client using [API key](https://developers.google.com/maps/documentation/directions/get-api-key#before-you-begin):

```
$gmaps = new \kalanis\google_maps\Client(
    new \PsrMock\Psr7\Request(),
    new \PsrMock\Psr18\Client(),
    new \kalanis\google_maps\ConfigClient('Your API Key'),
);
```

#### Language

[](#language)

You could set language for Client for all services:

```
$gmaps = new \kalanis\google_maps\Client(
    new \PsrMock\Psr7\Request(),
    new \PsrMock\Psr18\Client(),
    new \kalanis\google_maps\ConfigClient('Your API Key', 'pt-br'),
);
```

> [list of supported languages - Google Maps Platform](https://developers.google.com/maps/faq#languagesupport)

### APIs

[](#apis)

#### Elevation API

[](#elevation-api)

[Elevation API overview | Google for Developers](https://developers.google.com/maps/documentation/elevation/overview)

```
// Get elevation by locations parameter
$elevationResult = $gmaps->elevation(25.0339639, 121.5644722);
$elevationResult = $gmaps->elevation('25.0339639', '121.5644722');
```

#### Routes API

[](#routes-api)

[Get a route | Google for Developers](https://developers.google.com/maps/documentation/routes/compute_route_directions)

```
$routes = $gmaps->computeRoutes($originArray, $destinationArray, $fullBodyArray, $fieldMask)

// Get the route data between two places simply
$routes = $gmaps->computeRoutes([
        "location" => [
           "latLng" => [
              "latitude" => 37.419734,
              "longitude" => -122.0827784
           ]
        ]
    ],
    [
        "location" => [
           "latLng" => [
              "latitude" => 37.41767,
              "longitude" => -122.079595
           ]
        ]
    ]);

// Get the full route data between two places with full request data
$routes = $gmaps->computeRoutes([...], [...], ["travelMode": "DRIVE", ...], '*');
```

#### Roads API

[](#roads-api)

[Snap to Roads | Google for Developers](https://developers.google.com/maps/documentation/roads/snap)

```
$roads = $gmaps->snapToRoads([[-35.27801,149.12958], [-35.28032,149.12907], [-35.28099,149.12929]]);
```

#### Directions API

[](#directions-api)

[Getting directions | Google for Developers](https://developers.google.com/maps/documentation/directions/get-directions)

```
// Request directions via public transit
$directionsResult = $gmaps->directions('Milano', 'Venezia', [
    'mode' => "transit",
    'departure_time' => time(),
]);
```

#### Distance Matrix API

[](#distance-matrix-api)

[Get started with the Distance Matrix API | Google for Developers](https://developers.google.com/maps/documentation/distance-matrix/start)

```
// Get the distance matrix data between two places
$distanceMatrixResult = $gmaps->distanceMatrix('Canberra', 'Perth');

// With Imperial units
$distanceMatrixResult = $gmaps->distanceMatrix('Stonehenge', 'Bristol', [
    'units' => 'imperial',
]);
```

#### Geocoding API

[](#geocoding-api)

[Geocoding API overview | Google for Developers](https://developers.google.com/maps/documentation/geocoding/overview)

```
// Geocoding an address
$geocodeResult = $gmaps->geocode('Avenida Maracanã 350, Rio de Janeiro');

// Look up an address with reverse geocoding
$reverseGeocodeResult = $gmaps->reverseGeocode(-22.912167, -43.230164);
```

#### Geolocation API

[](#geolocation-api)

[Geolocation API overview | Google for Developers](https://developers.google.com/maps/documentation/geolocation/overview)

```
// Simple geolocate
$geolocateResult = $gmaps->geolocate([]);
```

#### Time Zone API

[](#time-zone-api)

[Time Zone API overview | Google for Developers](https://developers.google.com/maps/documentation/timezone/overview)

```
// requests the time zone data for given location
$timezoneResult = $gmaps->timezone([25.381111, 83.021389]); // Sárnáth
```

### Nearby API

[](#nearby-api)

[Nearby API overview | Google for Developers](https://developers.google.com/maps/documentation/places/web-service/search)

```
// requests the nearby points for given location
$nearbyResult = $gmaps->nearby('restaurant', [25.71874, 32.6574]); // in Luxor
```

### Find by Place API

[](#find-by-place-api)

[Find by Place API overview | Google for Developers](https://developers.google.com/maps/documentation/places/web-service/search)

```
// requests the place points for given location by given place
$nearbyResult = $gmaps->findPlace('Champs Elysees', 'restaurant', ['name', 'current_opening_hours']);
```

### Find by Text API

[](#find-by-text-api)

[Find by Text API overview | Google for Developers](https://developers.google.com/maps/documentation/places/web-service/search)

```
// requests the place points for given location by given text
$nearbyResult = $gmaps->findText('Sagrada Familia', 350, [], 3, 0, true);
```

### Place details API

[](#place-details-api)

[Place details API overview | Google for Developers](https://developers.google.com/maps/documentation/places/web-service/search)

```
// requests the details about place point
$nearbyResult = $gmaps->placeDetails('ChIJN1t_tDeuEmsRUsoyG83frY4', ['name', 'current_opening_hours']);
```

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance84

Actively maintained with recent releases

Popularity5

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 62.9% 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 ~286 days

Total

3

Last Release

80d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/499b0a541b787cdb31412f578c7b94c9790bcbee7de12c65b6101c6ce45ef6f0?d=identicon)[alex-kalanis](/maintainers/alex-kalanis)

---

Top Contributors

[![alex-kalanis](https://avatars.githubusercontent.com/u/59184183?v=4)](https://github.com/alex-kalanis "alex-kalanis (56 commits)")[![yidas](https://avatars.githubusercontent.com/u/12604195?v=4)](https://github.com/yidas "yidas (29 commits)")[![dereuromark](https://avatars.githubusercontent.com/u/39854?v=4)](https://github.com/dereuromark "dereuromark (3 commits)")[![genesiscz](https://avatars.githubusercontent.com/u/1512353?v=4)](https://github.com/genesiscz "genesiscz (1 commits)")

---

Tags

phpsdkservicesgoogle maps

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/alex-kalanis-google-maps-php-services/health.svg)

```
[![Health](https://phpackages.com/badges/alex-kalanis-google-maps-php-services/health.svg)](https://phpackages.com/packages/alex-kalanis-google-maps-php-services)
```

###  Alternatives

[openai-php/client

OpenAI PHP is a supercharged PHP API client that allows you to interact with the Open AI API

5.8k22.6M232](/packages/openai-php-client)[theodo-group/llphant

LLPhant is a library to help you build Generative AI applications.

1.5k311.5k5](/packages/theodo-group-llphant)[yidas/google-maps-services

PHP client library(SDK) for Google Maps API Web Services

721.3M](/packages/yidas-google-maps-services)[mozex/anthropic-php

Anthropic PHP is a supercharged community-maintained PHP API client that allows you to interact with Anthropic API.

46365.1k13](/packages/mozex-anthropic-php)[deepseek-php/deepseek-php-client

deepseek PHP client is a robust and community-driven PHP client library for seamless integration with the Deepseek API, offering efficient access to advanced AI and data processing capabilities.

47073.9k5](/packages/deepseek-php-deepseek-php-client)[softcreatr/php-mistral-ai-sdk

A powerful and easy-to-use PHP SDK for the Mistral AI API, allowing seamless integration of advanced AI-powered features into your PHP projects.

1517.9k](/packages/softcreatr-php-mistral-ai-sdk)

PHPackages © 2026

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