PHPackages                             martijnoud/distancematrix - 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. martijnoud/distancematrix

ActiveLibrary[API Development](/categories/api)

martijnoud/distancematrix
=========================

API wrapper to get the distance between two addresses using Google's Distance Matrix API

v1.2.0(9y ago)51.9k5[1 issues](https://github.com/MartijnOud/DistanceMatrix/issues)MITPHP

Since Jun 22Pushed 9y ago3 watchersCompare

[ Source](https://github.com/MartijnOud/DistanceMatrix)[ Packagist](https://packagist.org/packages/martijnoud/distancematrix)[ RSS](/packages/martijnoud-distancematrix/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)DependenciesVersions (3)Used By (0)

DistanceMatrix PHP API Wrapper
==============================

[](#distancematrix-php-api-wrapper)

Very simple API Wrapper for Google's DistanceMatrix API. Enter two addresses and the class returns the distance between them in meter. Alternatively use Google Static Map API to generate a map with a line plotted between two adresses.

Install
-------

[](#install)

Install using composer:

```
$ composer require martijnoud/distancematrix

```

Basic usage
-----------

[](#basic-usage)

Calculate the distance in meters between the [Inktweb.nl office](https://www.inktweb.nl/) and Paleis Noordeinde in the Hague.

```
use MartijnOud\DistanceMatrix\DistanceMatrix;

$distanceMatrix = new DistanceMatrix(YOUR_API_KEY_HERE);

$distance = $distanceMatrix->distance([
    'origins' => 'Prof. van der Waalsstraat 2 Alkmaar',
    'destinations' => 'Paleis Noordeinde Den Haag'
]);

if ($distance > 0) {
	echo round($distance / 1000, 2) . "km"; // 84.5km
}
```

More control
------------

[](#more-control)

```
use MartijnOud\DistanceMatrix\DistanceMatrix;

$distanceMatrix = new DistanceMatrix(YOUR_API_KEY_HERE);

$distance = $distanceMatrix->distance([
	'origins' => 'Leith',
	'destinations' => 'Arques',
	'mode' => 'walking',
	'language' => 'en-GB',
]);

if ($distance > 0) {
	echo "I would walk " . $distance * 0.00062137119 . " miles"; // I would walk 493.88322020532 miles
}
```

Generating a map
----------------

[](#generating-a-map)

An API key is not required for this. If you do supply a key make sure this key has premission to use the Static Map API.

```
use MartijnOud\DistanceMatrix\DistanceMatrix;

$distanceMatrix = new DistanceMatrix();

$image = $distanceMatrix->map([
	'origins' => 'Prof. van der Waalsstraat 2 Alkmaar', // required
	'destinations' => 'Amsterdam', // required
	'size' => '728x200'
]);

if ($image) {
	echo '';
}
```

[![google-static-map](https://cloud.githubusercontent.com/assets/1292436/8251065/aba708ce-1679-11e5-8f26-95f8627fcb63.png)](https://cloud.githubusercontent.com/assets/1292436/8251065/aba708ce-1679-11e5-8f26-95f8627fcb63.png)

Todo
----

[](#todo)

Ideas for future versions.

- Better error handling, checking rate limit, etc
- Show a map with a line plotted between two points

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance16

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 66.7% 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

3386d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0e61e288a27bea3d7da858fafd9c53b0d6a80d5369717d93498aab60c5952df3?d=identicon)[MartijnOud](/maintainers/MartijnOud)

---

Top Contributors

[![spamoom](https://avatars.githubusercontent.com/u/99203?v=4)](https://github.com/spamoom "spamoom (2 commits)")[![MartijnOud](https://avatars.githubusercontent.com/u/1292436?v=4)](https://github.com/MartijnOud "MartijnOud (1 commits)")

### Embed Badge

![Health badge](/badges/martijnoud-distancematrix/health.svg)

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

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[facebook/php-business-sdk

PHP SDK for Facebook Business

90821.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

74513.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

265103.1M454](/packages/google-gax)[google/common-protos

Google API Common Protos for PHP

173103.7M50](/packages/google-common-protos)

PHPackages © 2026

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