PHPackages                             szymsza/ppl-create-package-label-api - 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. szymsza/ppl-create-package-label-api

ActiveLibrary[API Development](/categories/api)

szymsza/ppl-create-package-label-api
====================================

A PHP package using OAUTH implementation to allow easier communication with PPL CPL API (aka MyAPI2).

v0.0.6(1mo ago)11.4k↑73.3%2MITPHPPHP ^7.4 || ^8.0

Since Aug 7Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/szymsza/php-ppl-create-package-label-api)[ Packagist](https://packagist.org/packages/szymsza/ppl-create-package-label-api)[ RSS](/packages/szymsza-ppl-create-package-label-api/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (5)Dependencies (6)Versions (7)Used By (0)

PPL MyApi2 client in PHP
========================

[](#ppl-myapi2-client-in-php)

PPL (Professional Parcel Logistic) recently launched a new version of their API called Create package label or MyApi2.

This package allows you to connect to the API by simply providing your credentials without the need to set up OAuth.

Further, it offers some helper functions for encoding requests or decoding responses. Optionally, it can cache the token across requests when [a class implementing Psr\\SimpleCache\\CacheInterface](https://packagist.org/providers/psr/simple-cache-implementation) is passed. This is highly recommended since the PPL quota for requesting new tokens (12 per minute) can be easily exceeded.

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

[](#requirements)

- PHP 7.4 or higher

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

[](#installation)

```
$ composer require szymsza/ppl-create-package-label-api
```

Credentials
-----------

[](#credentials)

You must request your credentials and the API documentation from PPL support. Klient.ppl.cz credentials will **not** work.

Usage
-----

[](#usage)

The library's primary purpose is being only an OAuth wrapper dealing with authentication. Therefore, for most endpoints you will need to send raw requests and parse the received data yourself.

However, a simple example covering frequent use cases can be found in `example/example.php`. After filling in your credentials, the script should work without any further configuration. After consulting this example script and the API documentation, using other endpoints should be intuitive.

### Initializing the client

[](#initializing-the-client)

```
$clientId = 'XXX';
$clientSecret = 'YYY';
$development = true;
$cache = new SomeCacheImplementingPsr16();  // optional
$ppl = new PPL($clientId, $clientSecret, $development, $cache);
```

### Basic connection

[](#basic-connection)

Call the API to get basic information, such as the API version or the current timee. Useful to test your connection.

```
var_dump($ppl->versionInformation());
```

Call the API to get Swaggger JSON describing the available API endpoints. You can view this JSON by pasting it, e.g., to .

```
var_dump($ppl->getSwagger());
```

### Request methods

[](#request-methods)

The class offers three methods to initiate requests:

- `requestJson(string $path, string $method = 'get', array $data = []): array|object|null` initiates the request and returns the response as a decoded JSON array or object. This is useful in case the response of the endpoint is JSON and you do not care about the received headers.
- `requestHeader(string $path, string $method = 'get', array $data = [], string $header = 'Location'): string` initiates the request and returns the value of a single header from the response. This is useful in case you do not care about the response body or values of other headers.
- `request(string $path, string $method = 'get', array $data = [])` initiates the request and returns the raw `ResponseInterface` object. This is useful in case you cannot use either of the methods above, e.g., if you need both the response body and the headers.

For examply, you can use `requestJson` to fetch available products like this:

```
var_dump($ppl->requestJson('codelist/product?limit=50&offset=0'));
```

### Creating a shipment label

[](#creating-a-shipment-label)

```
// Initialize the label batch
$batchUrl = $ppl->requestHeader('shipment/batch', 'post', [
    "labelSettings" => [
        "format" => "Pdf",
        "completeLabelSettings" => [
            "isCompleteLabelRequested" => true,
            "pageSize" => "A4"
        ]
    ],
    "shipments" => [
        [
            "referenceId" => "fe125c3a-3a36-487b-9e2b-e8919910ff63",
            "productType" => "BUSS",
            "sender" => [
                "street" => "Novoveská 1262/95",
                "city" => "Ostrava",
                "zipCode" => "70900",
                "country" => "CZ",
                "phone" => "+420777888999",
                "email" => "sender@email.cz"
            ],
            "recipient" => [
                "street" => "Františka a Anny Ryšových 1168",
                "city" => "Ostrava-Svinov",
                "zipCode" => "72100",
                "country" => "CZ",
                "phone" => "+420666777888",
                "email" => "recipient@email.cz"
            ]
        ]
    ],
    "shipmentsOrderBy" => "ShipmentNumber"
]);

// Wait for the label to be created on the server
// Note - you probably want to use some smarter solution on production...
do {
    sleep(1);

    // Get the batch result
    $batchStatus = $ppl->requestJson($batchUrl);
} while ($batchStatus->items[0]->importState !== "Complete");

// Save the two types of labels for the first shipment
$bigLabelUrl = $ppl->relativizeUrl($batchStatus->completeLabel->labelUrls[0]);
$singleLabelUrl = $ppl->relativizeUrl($batchStatus->items[0]->labelUrl);

file_put_contents("big.pdf", $ppl->request($bigLabelUrl)->getBody()->getContents());
file_put_contents("single.pdf", $ppl->request($singleLabelUrl)->getBody()->getContents());
```

For using other endpoints consult the documentation and pick one of the adequate `request` methods mentioned above.

###  Health Score

44

—

FairBetter than 90% of packages

Maintenance92

Actively maintained with recent releases

Popularity24

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 83.3% 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 ~139 days

Recently: every ~170 days

Total

6

Last Release

41d ago

PHP version history (3 changes)v0.0.1PHP ^7.4

v0.0.2PHP ^7.4 || ^8.0

v0.0.3PHP ^7.3 || ^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/12534237?v=4)[Jakub Szymsza](/maintainers/szymsza)[@szymsza](https://github.com/szymsza)

---

Top Contributors

[![szymsza](https://avatars.githubusercontent.com/u/12534237?v=4)](https://github.com/szymsza "szymsza (10 commits)")[![OndrejVasicek](https://avatars.githubusercontent.com/u/3864012?v=4)](https://github.com/OndrejVasicek "OndrejVasicek (2 commits)")

### Embed Badge

![Health badge](/badges/szymsza-ppl-create-package-label-api/health.svg)

```
[![Health](https://phpackages.com/badges/szymsza-ppl-create-package-label-api/health.svg)](https://phpackages.com/packages/szymsza-ppl-create-package-label-api)
```

###  Alternatives

[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

762297.9k53](/packages/civicrm-civicrm-core)[algolia/algoliasearch-client-php

API powering the features of Algolia.

69735.8M179](/packages/algolia-algoliasearch-client-php)[team-reflex/discord-php

An unofficial API to interact with the voice and text service Discord.

1.1k434.3k26](/packages/team-reflex-discord-php)[azuracast/azuracast

The AzuraCast self-hosted web radio station management suite.

4.0k27.9k](/packages/azuracast-azuracast)[tempest/framework

The PHP framework that gets out of your way.

2.3k37.6k21](/packages/tempest-framework)[showdoc/showdoc

ShowDoc is a tool greatly applicable for an IT team to share documents online

12.8k7.1k](/packages/showdoc-showdoc)

PHPackages © 2026

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