PHPackages                             geotab/mygeotab-php - 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. geotab/mygeotab-php

ActiveLibrary[API Development](/categories/api)

geotab/mygeotab-php
===================

Unofficial PHP client for the MyGeotab API

2.0.0(1y ago)5338.4k—3.2%23MITPHPPHP &gt;=7.1.0CI passing

Since Mar 29Pushed 1w ago6 watchersCompare

[ Source](https://github.com/Geotab/mygeotab-php)[ Packagist](https://packagist.org/packages/geotab/mygeotab-php)[ RSS](/packages/geotab-mygeotab-php/feed)WikiDiscussions main Synced 2w ago

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

MyGeotab PHP API Client
=======================

[](#mygeotab-php-api-client)

[![CI](https://camo.githubusercontent.com/52bb8fadb2a006749182c35d14b067a4bd23eff0ba7247729c2620419dad2e11/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f47656f7461622f6d7967656f7461622d7068702f63692e796d6c3f6272616e63683d6d61696e266c6162656c3d4349)](https://github.com/Geotab/mygeotab-php/actions/workflows/ci.yml)[![Latest Version](https://camo.githubusercontent.com/c337764295d71070ab5cb46538745a8c0128eb4b2d0ed2556c97f737b66b493b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f67656f7461622f6d7967656f7461622d7068702e737667)](https://packagist.org/packages/geotab/mygeotab-php)[![Monthly Downloads](https://camo.githubusercontent.com/df8b80746382c8a9227ba5d3a59fcee8195e4e831f692ffc8172607831ae704e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f67656f7461622f6d7967656f7461622d7068702e737667)](https://packagist.org/packages/geotab/mygeotab-php)[![License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](LICENSE)

PHP client for the [MyGeotab](https://www.geotab.com) API.

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

[](#requirements)

- PHP **&gt;=8.1**
- [Composer](https://getcomposer.org/)

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

[](#installation)

```
composer require geotab/mygeotab-php
```

Quick Start
-----------

[](#quick-start)

```
// Store credentials in environment variables, not in source code
$api = new Geotab\API(
    getenv('MYGEOTAB_USERNAME'),
    getenv('MYGEOTAB_PASSWORD'),
    getenv('MYGEOTAB_DATABASE')
);
$api->authenticate();

$results = $api->get("Device", ["resultsLimit" => 1]);
```

**Constructor:** `new Geotab\API($username, $password, $database, $server = "my.geotab.com")`

The `$server` parameter defaults to `my.geotab.com`. After `authenticate()`, it is updated automatically if the account lives on a different server node.

### Error handling

[](#error-handling)

Methods return results directly and throw `Geotab\MyGeotabException` on error:

```
use Geotab\MyGeotabException;

try {
    $toDate   = new DateTime();
    $fromDate = new DateTime();
    $fromDate->modify("-1 month");

    $violations = $api->get("DutyStatusViolation", [
        "search" => [
            "userSearch" => ["id" => "b1"],
            "toDate"     => $toDate->format("c"),
            "fromDate"   => $fromDate->format("c"),
        ],
        "resultsLimit" => 10,
    ]);

    echo "The driver has " . count($violations) . " violations!";
} catch (MyGeotabException $e) {
    // Handle API error
}
```

All methods also accept optional success and error callbacks if you prefer that style:

```
$api->get(
    "Device",
    ["resultsLimit" => 1],
    function ($results) { var_dump($results); },
    function ($error)   { var_dump($error); }
);
```

Logging
-------

[](#logging)

The library does not log internally. To log HTTP requests and responses, pass a pre-configured Guzzle client with a [log middleware](https://docs.guzzlephp.org/en/stable/handlers-and-middleware.html) attached. This works with any [PSR-3](https://www.php-fig.org/psr/psr-3/) compatible logger such as [Monolog](https://github.com/Seldaek/monolog):

```
composer require monolog/monolog
```

```
use GuzzleHttp\Client;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Middleware;
use GuzzleHttp\MessageFormatter;
use Monolog\Logger;
use Monolog\Handler\StreamHandler;

$logger = new Logger('mygeotab');
$logger->pushHandler(new StreamHandler('mygeotab.log'));

$stack = HandlerStack::create();
$stack->push(Middleware::log($logger, new MessageFormatter('{method} {uri} → {code}')));

$api = new Geotab\API(
    getenv('MYGEOTAB_USERNAME'),
    getenv('MYGEOTAB_PASSWORD'),
    getenv('MYGEOTAB_DATABASE'),
    'my.geotab.com',
    new Client(['handler' => $stack])
);
$api->authenticate();
```

API Reference
-------------

[](#api-reference)

MethodDescription`authenticate()`Exchanges credentials for a session token. Updates `$server` automatically if the account is on a different node.`get($type, $params)`Retrieves or searches for entities.`add($type, $entity)`Creates a new entity.`set($type, $entity)`Updates an existing entity.`remove($type, $entity)`Deletes an entity.`call($method, $params)`Calls any MyGeotab API method by name.`multiCall($calls)`Executes multiple API calls in a single HTTP request.`getCredentials()`Returns the current `Geotab\Credentials` object.`setCredentials($credentials)`Replaces the current credentials.See the [Geotab SDK documentation](https://developers.geotab.com) for available entity types, methods, and search parameters.

Examples
--------

[](#examples)

The `examples/` directory contains two runnable samples.

**CLI sample** — exercises Get, Set, Add, and MultiCall against a live database:

```
MYGEOTAB_USERNAME=user@example.com \
MYGEOTAB_PASSWORD=password \
MYGEOTAB_DATABASE=DatabaseName \
php examples/cli-sample.php
```

**Top Speeding Violations** — a web UI example. Serve with PHP's built-in server:

```
php -S localhost:7000 -t examples/top-speeding-violations/web
```

Then open `http://localhost:7000` in your browser.

Contributing
------------

[](#contributing)

Clone the repo and install dependencies:

```
git clone https://github.com/Geotab/mygeotab-php.git
cd mygeotab-php
composer install
```

Run the test suite:

```
vendor/bin/phpunit
```

Integration tests require credentials supplied as environment variables; they are skipped automatically if not set:

```
MYGEOTAB_USERNAME=user@example.com \
MYGEOTAB_PASSWORD=password \
MYGEOTAB_DATABASE=DatabaseName \
vendor/bin/phpunit
```

Pull requests are welcome. For major changes, open an issue first to discuss what you'd like to change.

License
-------

[](#license)

MIT © Geotab. See [LICENSE](LICENSE) for details.

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance72

Regular maintenance activity

Popularity44

Moderate usage in the ecosystem

Community16

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 98.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

Every ~808 days

Total

5

Last Release

535d ago

Major Versions

1.2.1 → 2.0.02025-02-04

PHP version history (2 changes)1.0.0PHP &gt;=5.3.3

1.1.0PHP &gt;=7.1.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/8283f82afba84cc17803f06e92b250c16f6245d619733e2c196ba269eacd948c?d=identicon)[colonelchlorine](/maintainers/colonelchlorine)

---

Top Contributors

[![colonelchlorine](https://avatars.githubusercontent.com/u/1085938?v=4)](https://github.com/colonelchlorine "colonelchlorine (78 commits)")[![symartensv2v](https://avatars.githubusercontent.com/u/102972677?v=4)](https://github.com/symartensv2v "symartensv2v (1 commits)")

---

Tags

apisdkgeotabmygeotab

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/geotab-mygeotab-php/health.svg)

```
[![Health](https://phpackages.com/badges/geotab-mygeotab-php/health.svg)](https://phpackages.com/packages/geotab-mygeotab-php)
```

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.6M3.2k](/packages/craftcms-cms)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

293.1k](/packages/eslazarev-wildberries-sdk)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k16](/packages/tempest-framework)[checkout/checkout-sdk-php

Checkout.com SDK for PHP

563.6M13](/packages/checkout-checkout-sdk-php)[files.com/files-php-sdk

Files.com PHP SDK

2481.1k](/packages/filescom-files-php-sdk)[lion/bundle

Lion-framework configuration and initialization package

122.4k4](/packages/lion-bundle)

PHPackages © 2026

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