PHPackages                             rudiullon/php-onfleet - 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. rudiullon/php-onfleet

ActiveLibrary[API Development](/categories/api)

rudiullon/php-onfleet
=====================

Onfleet's PHP API Wrapper Package

v1.0.4(3y ago)027MITPHPPHP &gt;=7.4

Since May 13Pushed 3y agoCompare

[ Source](https://github.com/rudiullon/php-onfleet)[ Packagist](https://packagist.org/packages/rudiullon/php-onfleet)[ Docs](https://onfleet.com/)[ RSS](/packages/rudiullon-php-onfleet/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (8)Dependencies (2)Versions (6)Used By (0)

Onfleet PHP Wrapper
===================

[](#onfleet-php-wrapper)

[![License](https://camo.githubusercontent.com/242ca7a55ac0e9ce087a16212cac49e543251c1b246d5a8c33da74008c24de5b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6f6e666c6565742f7068702d6f6e666c656574)](https://github.com/onfleet/php-onfleet/blob/master/LICENSE)[![Latest version](https://camo.githubusercontent.com/152ec84f55f5a756225b2255f4898fb1347ad35e485ec83ce6d1322ec8515880/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6f6e666c6565742f7068702d6f6e666c656574)](https://packagist.org/packages/onfleet/php-onfleet)[![Top language](https://camo.githubusercontent.com/93e68920ab09182d0c23db2dbe968f901e7c107c54f51a8fa3d15cf2dd65161f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c616e6775616765732f746f702f6f6e666c6565742f7068702d6f6e666c656574)](https://camo.githubusercontent.com/93e68920ab09182d0c23db2dbe968f901e7c107c54f51a8fa3d15cf2dd65161f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c616e6775616765732f746f702f6f6e666c6565742f7068702d6f6e666c656574)[![Downloads](https://camo.githubusercontent.com/ca5763ec7a651e0aea35d6ed91c4de5644bfd2827b8b62531bc39bfdaebfe33b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f6f6e666c6565742f7068702d6f6e666c656574)](https://packagist.org/packages/onfleet/php-onfleet)

> *Read this document in another language*: [Español](https://github.com/onfleet/php-onfleet/blob/master/README.es.md)

Visit our blog post on the [API wrapper project](https://onfleet.com/blog/api-wrappers-explained/) to learn more about our initiatives. If you have any questions, please reach us by submitting an issue [here](https://github.com/onfleet/php-onfleet/issues) or contact .

### Table of contents

[](#table-of-contents)

- [Table of contents](#table-of-contents)
- [Synopsis](#synopsis)
- [Installation](#installation)
- [Requirements](#requirements)
- [Usage](#usage)
    - [Authentication](#authentication)
    - [Throttling](#throttling)
    - [Supported CRUD operations](#supported-crud-operations)
        - [GET Requests](#get-requests)
            - [Examples of `get()`](#examples-of-get)
            - [Examples of `get(param)`](#examples-of-getparam)
            - [Examples of `getByLocation`](#examples-of-getbylocation)
        - [POST Requests](#post-requests)
            - [Examples of `create()`](#examples-of-create)
        - [PUT Requests](#put-requests)
            - [Examples of `update()`](#examples-of-update)
            - [Examples of `insertTask()`](#examples-of-inserttask)
        - [DELETE Requests](#delete-requests)
            - [Examples of `deleteOne()`](#examples-of-deleteone)
    - [Examples of utilizing your CRUD operations](#examples-of-utilizing-your-crud-operations)
    - [Things NOT to do](#things-not-to-do)

Synopsis
--------

[](#synopsis)

The Onfleet PHP library provides convenient access to the Onfleet API.

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

[](#installation)

```
composer require onfleet/php-onfleet

```

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

[](#requirements)

The Onfleet PHP library requires bcmath extension to be [installed](https://www.php.net/manual/es/bc.installation.php).

Usage
-----

[](#usage)

Before using the API wrapper, you will need to obtain an API key from one of your organization's admins.

Creation and integration of API keys are performed through the [Onfleet dashboard](https://onfleet.com/dashboard#/manage).

To start utilizing the library, you simply need to create an `Onfleet` object with your API key:

```
$onfleet = new Onfleet("");
```

Optionally, you can introduce a customized timeout that is less than the default Onfleet API timeout (70,000 ms) by providing a 2nd parameter:

```
$onfleet = new Onfleet("", 30000);
```

### Authentication

[](#authentication)

Once the `Onfleet` object is created, you can test on the authentication endpoint:

```
$onfleet->verifyKey();  // Returns a boolean
```

### Throttling

[](#throttling)

Rate limiting is enforced by the API with a threshold of 20 requests per second across all your organization's API keys. Learn more about it [here](https://docs.onfleet.com/reference#throttling).

We have also implemented a limiter on this library to avoid you from unintentionally exceeding your rate limitations and eventually be banned for.

### Supported CRUD Operations

[](#supported-crud-operations)

Here are the operations available for each entity:

EntityGETPOSTPUTDELETE[Admins/Administrators](https://docs.onfleet.com/reference#administrators)get()create(obj), matchMetadata(obj)update(id, obj)deleteOne(id)[Containers](https://docs.onfleet.com/reference#containers)get(id, 'workers'), get(id, 'teams'), get(id, 'organizations')xupdate(id, obj)x[Destinations](https://docs.onfleet.com/reference#destinations)get(id)create(obj), matchMetadata(obj)xx[Hubs](https://docs.onfleet.com/reference#hubs)get()create(obj)update(id, obj)x[Organization](https://docs.onfleet.com/reference#organizations)get(), get(id)xinsertTask(id, obj)x[Recipients](https://docs.onfleet.com/reference#recipients)get(id), get(name, 'name'), get(phone, 'phone')create(obj), matchMetadata(obj)update(id, obj)x[Tasks](https://docs.onfleet.com/reference#tasks)get(query), get(id), get(shortId, 'shortId')create(obj), clone(id), forceComplete(id), batch(obj), autoAssign(obj), matchMetadata(obj)update(id, obj)deleteOne(id)[Teams](https://docs.onfleet.com/reference#teams)get(), get(id), getWorkerEta(id, obj)create(obj), autoDispatch(id, obj)update(id, obj), insertTask(id, obj)deleteOne(id)[Webhooks](https://docs.onfleet.com/reference#webhooks)get()create(obj)xdeleteOne(id)[Workers](https://docs.onfleet.com/reference#workers)get(), get(query), get(id), getByLocation(obj), getSchedule(id)create(obj), setSchedule(id, obj), matchMetadata(obj)update(id, obj), insertTask(id, obj)deleteOne(id)#### GET Requests

[](#get-requests)

To get all the documents within an endpoint, this returns an array of results:

```
get();
```

##### Examples of `get()`

[](#examples-of-get)

```
$onfleet->workers->get();
$onfleet->workers->get($queryParams);
```

Optionally you can send an array of query params for some certain endpoints. Refer back to [API documentation](https://docs.onfleet.com/) for endpoints that support query parameters.

```
$onfleet->workers->get([ "phones" => "" ]);

$onfleet->tasks->get([ "from" => "", "to" => "" ]);
```

To get one of the documents within an endpoint, if the optional *paramName* is not provided, the library will search by ID. If *paramName* is provided, it will search by *paramName*:

```
get(,  (optional),  (optional));
```

*paramName* can be any of:

- `id`
- `name`
- `phone`
- `shortId`

##### Examples of `get(param)`

[](#examples-of-getparam)

```
$onfleet->workers->get("");
$onfleet->workers->get("", [ "analytics" => true ]);

$onfleet->tasks->get("", "shortId");

$onfleet->recipients->get("", "phone");
$onfleet->recipients->get("", "name");
$onfleet->recipients->get("", "name", [ "skipPhoneNumberValidation" => true ]);

$onfleet->containers->get("", "workers");
$onfleet->containers->get("", "teams");
$onfleet->containers->get("", "organizations");
```

To get a driver by location, use the `getByLocation` function:

```
getByLocation($queryParams);
```

##### Examples of `getByLocation`

[](#examples-of-getbylocation)

```
$locationParams = [
  "longitude" => -122.404,
  "latitude" => 37.789,
  "radius" => 10000,
];

$onfleet->workers->getByLocation($locationParams);
```

#### POST Requests

[](#post-requests)

To create a document within an endpoint:

```
create($data);
```

##### Examples of `create()`

[](#examples-of-create)

```
$data = [
  "name" => "John Driver",
  "phone" => "+16173428853",
  "teams" => ["", " (optional)", ...],
  "vehicle" => [
    "type" => "CAR",
    "description" => "Tesla Model 3",
    "licensePlate" => "FKNS9A",
    "color" => "purple",
  ],
];

$onfleet->workers->create($data);
```

Extended POST requests include `clone`, `forceComplete`, `batchCreate`, `autoAssign` on the *Tasks* endpoint; `setSchedule` on the *Workers* endpoint; `autoDispatch` on the *Teams* endpoint; and `matchMetadata` on all supported entities. For instance:

```
$onfleet->tasks->clone('');
$onfleet->tasks->forceComplete('', $data);
$onfleet->tasks->batchCreate($data);
$onfleet->tasks->autoAssign($data);

$onfleet->workers->setSchedule('', $data);

$onfleet->teams->autoDispatch('', $data);

$onfleet->->matchMetadata($data);
```

For more details, check our documentation on [`clone`](https://docs.onfleet.com/reference#clone-task), [`forceComplete`](https://docs.onfleet.com/reference#complete-task), [`batchCreate`](https://docs.onfleet.com/reference#create-tasks-in-batch), [`autoAssign`](https://docs.onfleet.com/reference#automatically-assign-list-of-tasks), [`setSchedule`](https://docs.onfleet.com/reference#set-workers-schedule), [`matchMetadata`](https://docs.onfleet.com/reference#querying-by-metadata), and [`autoDispatch`](https://docs.onfleet.com/reference#team-auto-dispatch).

#### PUT Requests

[](#put-requests)

To update a document within an endpoint:

```
update("", $data);
```

##### Examples of `update()`

[](#examples-of-update)

```
$newData = [
  "name" => "Jack Driver",
];

$onfleet->workers->update("", $newData);
```

##### Examples of `insertTask()`

[](#examples-of-inserttask)

```
$onfleet->workers->insertTask("", $data);
```

#### DELETE Requests

[](#delete-requests)

To delete a document within an endpoint:

```
deleteOne("");
```

##### Examples of `deleteOne()`

[](#examples-of-deleteone)

```
$onfleet->workers->deleteOne("");
```

### Examples of utilizing your CRUD operations

[](#examples-of-utilizing-your-crud-operations)

- Get all the recipients: ```
    try {
      $tasks = $onfleet->tasks->get([ "from" =>"1557936000000", "to" => "1558022400000" });
      foreach ($tasks['tasks'] as $task) {
        if (is_set($task['recipients'][0])) {
          // Do something with the recipients
        }
      }
    } catch (Exception $error) {
      // Do something with the error
    }
    ```

### Things NOT to do

[](#things-not-to-do)

- Inefficient pattern, use metadata instead:

    ```
    // DONT
    try {
      $workers = $onfleet->workers.get();
      for ($workers as $worker) {
        foreach ($worker['metadata'] as $metadataEntry) {
          if ($metadataEntry['name'] === "hasFreezer" && $metadataEntry['value']) {
            // Do something
          }
        }
      }
    } catch (Exception $error) {
      // Do something with the error
    }

    // DO
    try {
      $workers = $onfleet->workers->matchMetadata([["name" => "hasFreezer", "type" => "boolean", "value" => true]]);
      for ($workers as $worker) {
        // Do something
      }
    } catch (Exception $error) {
      // Do something with the error
    }
    ```

*Go to [top](#onfleet-php-wrapper)*.

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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

Total

5

Last Release

1196d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e8fe93c0acffa3e6f9baa52d636989da06181a2d654cc499f47fa3c5ea57e7d1?d=identicon)[rudiullon](/maintainers/rudiullon)

---

Top Contributors

[![rudiullon](https://avatars.githubusercontent.com/u/9945644?v=4)](https://github.com/rudiullon "rudiullon (8 commits)")[![YokySantiago](https://avatars.githubusercontent.com/u/39206812?v=4)](https://github.com/YokySantiago "YokySantiago (6 commits)")[![jamesliupenn](https://avatars.githubusercontent.com/u/18385437?v=4)](https://github.com/jamesliupenn "jamesliupenn (2 commits)")[![vic-onfleet](https://avatars.githubusercontent.com/u/80332034?v=4)](https://github.com/vic-onfleet "vic-onfleet (1 commits)")

---

Tags

OnFleetphp-onfleet

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/rudiullon-php-onfleet/health.svg)

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

###  Alternatives

[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

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

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/common-protos

Google API Common Protos for PHP

173103.7M50](/packages/google-common-protos)[hubspot/api-client

Hubspot API client

23414.2M16](/packages/hubspot-api-client)

PHPackages © 2026

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