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.5(9mo ago)1646↓33.3%2MITPHPPHP ^7.4 || ^8.0

Since Aug 7Pushed 9mo 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 1mo ago

READMEChangelog (4)Dependencies (3)Versions (6)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

33

—

LowBetter than 75% of packages

Maintenance56

Moderate activity, may be stable

Popularity20

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 Bus Factor1

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

Total

5

Last Release

288d 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://www.gravatar.com/avatar/2d490806a65234c43797c4e196797f9fddd513f5e4fa8bb31770a027d89cc52b?d=identicon)[szymsza](/maintainers/szymsza)

---

Top Contributors

[![szymsza](https://avatars.githubusercontent.com/u/12534237?v=4)](https://github.com/szymsza "szymsza (9 commits)")[![OndrejVasicek](https://avatars.githubusercontent.com/u/3864012?v=4)](https://github.com/OndrejVasicek "OndrejVasicek (1 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

[algolia/algoliasearch-client-php

API powering the features of Algolia.

69333.0M114](/packages/algolia-algoliasearch-client-php)[civicrm/civicrm-core

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

728272.9k20](/packages/civicrm-civicrm-core)[thecodingmachine/graphqlite

Write your GraphQL queries in simple to write controllers (using webonyx/graphql-php).

5723.1M30](/packages/thecodingmachine-graphqlite)[team-reflex/discord-php

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

1.1k379.4k24](/packages/team-reflex-discord-php)[dcblogdev/laravel-microsoft-graph

A Laravel Microsoft Graph API (Office365) package

168285.5k1](/packages/dcblogdev-laravel-microsoft-graph)[wordpress/php-ai-client

A provider agnostic PHP AI client SDK to communicate with any generative AI models of various capabilities using a uniform API.

26236.6k14](/packages/wordpress-php-ai-client)

PHPackages © 2026

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