PHPackages                             trunkrs/sdk - 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. trunkrs/sdk

ActiveLibrary[API Development](/categories/api)

trunkrs/sdk
===========

Trunkrs Client SDK

2.2.0(5y ago)4100.6k—9.6%1[1 issues](https://github.com/Trunkrs/Trunkrs-SDK-PHP/issues)MITPHPPHP &gt;=7.0.0CI failing

Since Mar 10Pushed 5y ago1 watchersCompare

[ Source](https://github.com/Trunkrs/Trunkrs-SDK-PHP)[ Packagist](https://packagist.org/packages/trunkrs/sdk)[ Docs](https://trunkrs.nl/)[ RSS](/packages/trunkrs-sdk/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (5)Versions (22)Used By (0)

Trunkrs SDK for PHP
===================

[](#trunkrs-sdk-for-php)

[![CI](https://github.com/Trunkrs/Trunkrs-SDK-PHP/workflows/CI/badge.svg?branch=master)](https://github.com/Trunkrs/Trunkrs-SDK-PHP/workflows/CI/badge.svg?branch=master)[![Coverage Status](https://camo.githubusercontent.com/49fdc21e83720e2a5d680e3040bd378440732dfa32b9bf7cdf532a4748d58e0c/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f5472756e6b72732f5472756e6b72732d53444b2d5048502f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/Trunkrs/Trunkrs-SDK-PHP?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/92f0604551bd8b55ee6d89f84ee07f303bf94b368498525f1223fb2f8c5fa7e7/68747470733a2f2f706f7365722e707567782e6f72672f7472756e6b72732f73646b2f76657273696f6e)](https://packagist.org/packages/trunkrs/sdk)[![License](https://camo.githubusercontent.com/f516b942001617770d58bc1ca645aa9855a9530ec96c67ad68a617b55ab8375c/68747470733a2f2f706f7365722e707567782e6f72672f7472756e6b72732f73646b2f6c6963656e7365)](https://packagist.org/packages/trunkrs/sdk)

The Trunkrs software development kit for the public client SDK. With this PHP SDK you can manage your shipments, shipment states and webhooks within our system.

> ### Migrate from version 1
>
> [](#migrate-from-version-1)
>
> Check out [our migration guide](MIGRATE.md) if you wish to migrate your v1 implementation of the Trunkrs SDK.

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

[](#requirements)

PHP 7.0 and later.

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

[](#installation)

You can install the SDK via [Composer](http://getcomposer.org/). Run the following command:

```
composer require trunkrs/sdk
```

To use the bindings, use Composer's [autoload](https://getcomposer.org/doc/01-basic-usage.md#autoloading):

```
require_once('vendor/autoload.php');
```

Dependencies
------------

[](#dependencies)

The SDK requires the following extensions in order to work properly:

- [`json`](https://secure.php.net/manual/en/book.json.php)
- [`guzzle/guzzle`](https://github.com/guzzle/guzzle) (optional, can be replaced)

If you use Composer, these dependencies should be handled automatically.

Getting started
---------------

[](#getting-started)

Setup the SDK settings before usage by supplying your merchant credentials. If you don't have any credentials yet, please contact [Trunkrs](https://trunkrs.nl) for more information.

```
\Trunkrs\SDK\Settings::setApiKey("your-trunkrs-api-key");
```

### Using staging

[](#using-staging)

To make use of the Trunkrs staging environment, which has been supplied to test your implementation with our system. The SDK can be switched easily.

```
\Trunkrs\SDK\Settings::useStaging();
```

Both API endpoints and the tracking URL's will point to the staging environment.

Shipments
---------

[](#shipments)

### Create a shipment

[](#create-a-shipment)

A shipment can be created through the `Shipment` class. It exposes a static method `Shipment::create(...)`.

```
$details = new \Trunkrs\SDK\ShipmentDetails();

$parcel = new \Trunkrs\SDK\Parcel();
// Set the reference of the parcel. This is required.
$parcel->reference = 'your-order-reference';

$details->parcels = [
    // Define which parcels are part of this shipment
    $parcel,
];

$details->sender = new \Trunkrs\SDK\Address();
// Set the pickup address properties.

$details->recipient = new \Trunkrs\SDK\Address();
// Set the delivery address properties.

$shipments = \Trunkrs\SDK\Shipment::create($details);
```

> #### International shipping
>
> [](#international-shipping)
>
> When shipping internationally we require you to define the contents of a parcel as well as the volume and weight of the parcel.

### Retrieve shipment details

[](#retrieve-shipment-details)

Details for a single shipment can be retrieved through its identifier by calling the `Shipment::find($trunkrsNr)` method.

```
$shipment = \Trunkrs\SDK\Shipment::find('4000002123');
```

### Retrieve shipment history

[](#retrieve-shipment-history)

Your shipment history can be listed in a paginated manner by using the `Shipment::retrieve($page)` method. Every returned page contains a maximum of 50 shipments.

```
$shipments = \Trunkrs\SDK\Shipment::retrieve();
```

### Cancel a shipment

[](#cancel-a-shipment)

Shipments can be canceled by their identifier or simply through the `cancel()` method on an instance of a `Shipment`.

The `Shipment` class exposes the `cancelByTrunkrsNr($trunkrsNr)` static method:

```
\Trunkrs\SDK\Shipment::cancelByTrunkrsNr('4000002123');
```

An instance of the `Shipment` class also exposes a convenience method `cancel()`:

```
$shipment = \Trunkrs\SDK\Shipment::find('4000002123');

$shipment->cancel();
```

Shipment State
--------------

[](#shipment-state)

To retrieve details about the shipment's current state and the current owner of the shipment. The `ShipmentState` class can be used which exposes the static `forShipment($shipmentId)` method.

```
$status = \Trunkrs\SDK\ShipmentState::forShipment('4000002123');
```

Web hooks
---------

[](#web-hooks)

To be notified about shipment state changes, Trunkrs has created a webhook notification service. The SDK allows the registration of a callback URL for notifications through this service.

### Register subscription

[](#register-subscription)

The `Webhook` class exposes a static method called `register($webhook)` which allows the registration of new web hooks:

```
$webhook = new \Trunkrs\SDK\Webhook();
$webhook->callbackUrl = "https://your.web.service/shipments/webhook";
$webhook->sessionHeaderName = 'X-SESSION-TOKEN';
$webhook->sessionToken = "your-secret-session-token";
$webhook->event = \Trunkrs\SDK\Enum\WebhookEvent::ON_STATE_UPDATE;

\Trunkrs\SDK\Webhook::register($webhook);
```

### Retrieve active subscriptions

[](#retrieve-active-subscriptions)

Your active webhook subscriptions can be listed using `Webhook::retrieve()`.

```
$webhooks = \Trunkrs\SDK\Webhook::retrieve();
```

### Cancel subscription

[](#cancel-subscription)

Canceling a web hook subscription can be done using `Webhook::removeById($webhookId)` or the instance method on an instance of webhook.

```
$webhookId = 100;

\Trunkrs\SDK\Webhook::removeById($webhookId);
```

```
$webhook = \Trunkrs\SDK\Webhook::find(100);

$webhook->remove();
```

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance15

Infrequent updates — may be unmaintained

Popularity36

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity60

Established project with proven stability

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

Recently: every ~8 days

Total

21

Last Release

1880d ago

Major Versions

1.2.4 → 2.0.02021-02-04

### Community

Maintainers

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

![](https://www.gravatar.com/avatar/f3bcbb00bd94ab9d96eb98b93b27547a931b79efe6a5159e0b7ec9190076ca3a?d=identicon)[Trunkrs OSS](/maintainers/Trunkrs%20OSS)

---

Top Contributors

[![hiddestokvis](https://avatars.githubusercontent.com/u/2144047?v=4)](https://github.com/hiddestokvis "hiddestokvis (6 commits)")[![basepack](https://avatars.githubusercontent.com/u/939500?v=4)](https://github.com/basepack "basepack (4 commits)")[![BBrunekreeft](https://avatars.githubusercontent.com/u/9114578?v=4)](https://github.com/BBrunekreeft "BBrunekreeft (2 commits)")[![Chlododev](https://avatars.githubusercontent.com/u/67639785?v=4)](https://github.com/Chlododev "Chlododev (2 commits)")[![fean](https://avatars.githubusercontent.com/u/642164?v=4)](https://github.com/fean "fean (2 commits)")

---

Tags

apisdkshipmenttrunkrsapilogisticstrunkrs

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/trunkrs-sdk/health.svg)

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

###  Alternatives

[openai-php/laravel

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

3.7k7.6M74](/packages/openai-php-laravel)[get-stream/stream-chat

A PHP client for Stream Chat (https://getstream.io/chat/)

301.8M2](/packages/get-stream-stream-chat)[convertkit/convertkitapi

Kit PHP SDK for the Kit API

2167.1k1](/packages/convertkit-convertkitapi)

PHPackages © 2026

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