PHPackages                             cpapdotcom/asendia - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. cpapdotcom/asendia

ActiveLibrary[HTTP &amp; Networking](/categories/http)

cpapdotcom/asendia
==================

Client for interacting with Asendia (asendia.com)

22.0kPHP

Since Jun 5Pushed 10y ago2 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

Asendia Integration
===================

[](#asendia-integration)

Provides integration with [Asendia](http://asendia.com).

[![Latest Stable Version](https://camo.githubusercontent.com/32e8945d9c0da3b661b16e14c8d62c54973ed0ec1e5f4c89fb8d3cd2b3e2ddf3/68747470733a2f2f706f7365722e707567782e6f72672f63706170646f74636f6d2f6173656e6469612f762f737461626c65)](https://packagist.org/packages/cpapdotcom/asendia)[![Total Downloads](https://camo.githubusercontent.com/ef29fa5f07dcb720c3f373e3760e23d7014a9907f86cd2dde460aeeeef787761/68747470733a2f2f706f7365722e707567782e6f72672f63706170646f74636f6d2f6173656e6469612f646f776e6c6f616473)](https://packagist.org/packages/cpapdotcom/asendia)[![Latest Unstable Version](https://camo.githubusercontent.com/9bb054a31464938e683c7eea7e17af0eec44ad05e445ead7485bf1623c540132/68747470733a2f2f706f7365722e707567782e6f72672f63706170646f74636f6d2f6173656e6469612f762f756e737461626c65)](https://packagist.org/packages/cpapdotcom/asendia)[![License](https://camo.githubusercontent.com/2fc1653a9984f66074a273f65b388874df2e7595d892009be84077a9f3c278bb/68747470733a2f2f706f7365722e707567782e6f72672f63706170646f74636f6d2f6173656e6469612f6c6963656e7365)](https://packagist.org/packages/cpapdotcom/asendia)
[![Build Status](https://camo.githubusercontent.com/3ed689d3b7e462d24d3e6455fea6f058310656c0ffd578e2be1004d394fde882/68747470733a2f2f7472617669732d63692e6f72672f63706170646f74636f6d2f6173656e6469612e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/cpapdotcom/asendia)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/9d35a386fcfce4c801e71e62c53b72904b1995da4d14740b2fdfa65d2d7ffc29/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f63706170646f74636f6d2f6173656e6469612f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/cpapdotcom/asendia/?branch=master)[![Code Climate](https://camo.githubusercontent.com/4d784c603e111a68053f904fdcd98550196a599e5abc17424f98af853c451502/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f63706170646f74636f6d2f6173656e6469612f6261646765732f6770612e737667)](https://codeclimate.com/github/cpapdotcom/asendia)

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

[](#requirements)

- PHP 5.4+

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

[](#installation)

### Using Composer

[](#using-composer)

```
$> composer require cpapdotcom/asendia
```

While in early development, you may be required to be a little more specific:

```
$> composer require cpapdotcom/asendia:^0.0@dev
```

### PSR-4 or PSR-0 Autoloading

[](#psr-4-or-psr-0-autoloading)

Configure [PSR-4](http://www.php-fig.org/psr/psr-4) to look in `src/Cpapdotcom/Asendia` with a namespace prefix of `Cpapdotcom\Asendia\`. For PSR-4, the trailing `\` is important.

Configure [PSR-0](http://www.php-fig.org/psr/psr-0) to look in `src/` for classes. Depending on PSR-0 implementation, the namespace prefix may be set to `Cpapdotcom\Asendia`.

### Standalone

[](#standalone)

This package ships with a standalone [PSR-4](http://www.php-fig.org/psr/psr-4)autoloader courtesy of [Aura](http://auraphp.com/). Require the `autoload.php`from the root of this package to make all of the classes in this package available to an application.

```
require_once '/path/to/cpapdotcom-asendia/autoload.php';
```

Basic Manifest Usage
--------------------

[](#basic-manifest-usage)

The Manifest is a programmatic representation of Asendia's Global eFile XML Data Import Specifications. The end result is to create a Simple XML Element instance that can be consumed by the Asendia Web API Client.

The `Cpapdotcom\Asendia\Manifest` class is a facade to the Manifest primitive types and tools to transform both `Manifest\Manifest` instances and property collections into Simple XML Elements. Its job is to simplify these tasks:

### Creating a Manifest for an account

[](#creating-a-manifest-for-an-account)

Creates a `Manifest\Manifest` with the current date and time for the timestamp.

```
use Cpapdotcom\Asendia\Manifest;

$manifest = Manifest::createManifestForAccount(
    $accountNumber,
    $companyName
);
```

Creates a `Manifest\Manifest` with the specific date and time for the timestamp.

```
use Cpapdotcom\Asendia\Manifest;

$manifest = Manifest::createManifestForAccount(
    $accountNumber,
    $companyName,
    new DateTime('yesterday')
);
```

### Creating a Package

[](#creating-a-package)

Creates a `Manifest\Package`.

```
use Cpapdotcom\Asendia\Manifest;

$package = Manifest::createPackageWithPckId($pckId);
```

### Creating an Item

[](#creating-an-item)

Creates a `Manifest\Item`.

```
use Cpapdotcom\Asendia\Manifest;

$package = Manifest::createItemForPackageWithItemId($itemId);
```

### Creating a Simple XML Element from a Manifest

[](#creating-a-simple-xml-element-from-a-manifest)

```
use Cpapdotcom\Asendia\Manifest;

$element = Manifest::createXmlFromManifest($manifest);
```

### Creating a Simple XML Element from a collection of properties

[](#creating-a-simple-xml-element-from-a-collection-of-properties)

```
use Cpapdotcom\Asendia\Manifest;

$element = Manifest::createXmlFromProperties($properties);
```

### Example

[](#example)

```
use Cpapdotcom\Asendia\Manifest;

$manifest = Manifest::createManifestForAccount(
    '123456789012345',
    'Your Company Name'
)
    ->withPackage(Manifest::createPackageWithPckId('BW00709000019')
        ->withOrderId('89105221002001100217')
        ->withLastName('Doe')
        ->withFirstName('Jane')
        ->withMiddleInitial('S')
        ->withAddressLines([
            '17 Robilliard Way',
        ])
        ->withCity('Sebastopol')
        ->withProvince('Bonshaw')
        ->withPostalCode('3356')
        ->withCountryCode('AU')
        //->withPhone()
        //->withEmail()
        ->withPckWeight('3.58')
        ->withPckType('M')
        ->withServiceType('PAR')
        ->withPckDescription('Clothing')
        ->withShippingCost('20.21')
        ->withDutyTaxHandling('10.83')
        ->withCustomsBarCode('LM473124829US')
        ->withItem(Manifest::createItemForPackageWithItemId('2929840')
            ->withItemDescription('Shirt')
            ->withCustomsDescription('Shirt')
            ->withQuantity(1)
            ->withUnitPrice('10.00')
            ->withCountryOfOrigin('US')
            ->withHTSNumber('123456789')
        )
        ->withItem(Manifest::createItemForPackageWithItemId('2929841')
            ->withItemDescription('Pants')
            ->withCustomsDescription('Pants')
            ->withQuantity(2)
            ->withUnitPrice('15.00')
            ->withCountryOfOrigin('US')
            ->withHTSNumber('987654321')
        )
    )
    ->withPackage(Manifest::createPackageWithPckId('BW00709012345')
        ->withOrderId('89105221002001100217')
        ->withLastName('Smith')
        ->withFirstName('John')
        ->withMiddleInitial('Q')
        ->withAddressLines([
            '28A CLIFTON ST',
            'Apartment 203',
        ])
        ->withCity('CAMPBELLTOWN')
        ->withProvince('SYDNEY')
        ->withPostalCode('2560')
        ->withCountryCode('AU')
        ->withPhone('jsmith@gmail.com')
        //->withEmail()
        ->withPckWeight('1.25')
        ->withPckType('S')
        ->withServiceType('PAR')
        ->withPckDescription('Clothing')
        //->withShippingCost()
        //->withDutyTaxHandling()
        ->withCustomsBarCode('LM473124829US')
        ->withItem(Manifest::createItemForPackageWithItemId('123456789')
            ->withItemDescription('Pants')
            ->withCustomsDescription('100% cotton')
            ->withQuantity(1)
            ->withUnitPrice('25.00')
            ->withCountryOfOrigin('US')
            //->withHTSNumber()
        )
    )
;

//
$manifestAsXml = Manifest::createXmlFromManifest($manifest);
```

Basic Asendia Web API Client Usage
----------------------------------

[](#basic-asendia-web-api-client-usage)

### Creating an Assendia Web API Client

[](#creating-an-assendia-web-api-client)

Create an Asendia Web API Client from login and password using the production WSDL URI.

```
use Cpapdotcom\Asendia\WebApiClient\Adapter\Soap\SoapAsendiaWebApiClient;

$asendia = SoapAsendiaWebApiClient::fromCredentialsAndProductionWsdl(
    $login,
    $password
);
```

Create an Asendia Web API Client from login and password using the testing WSDL URI.

```
use Cpapdotcom\Asendia\WebApiClient\Adapter\Soap\SoapAsendiaWebApiClient;

$asendia = SoapAsendiaWebApiClient::fromCredentialsAndTestingWsdl(
    $login,
    $password
);
```

Create an Asendia Web API Client from login and password using the WSDL URI specified.

```
use Cpapdotcom\Asendia\WebApiClient\Adapter\Soap\SoapAsendiaWebApiClient;

$asendia = SoapAsendiaWebApiClient::fromCredentialsAndWsdl(
    $login,
    $password,
    $wsdl
);
```

Example of how one might create an Asendia Web API Client from login and password using the WSDL URI for the current environment.

```
use Cpapdotcom\Asendia\WebApiClient\Adapter\Soap\SoapAsendiaWebApiClient;

$asendia = SoapAsendiaWebApiClient::fromCredentialsAndWsdl(
    $login,
    $password,
    $env === 'production'
        ? SoapAsendiaWebApiClient::PRODUCTION_WSDL
        : SoapAsendiaWebApiClient::TESTING_WSDL
);
```

### Create a shipment

[](#create-a-shipment)

```
$createdShipment = $asendia->createShipment();

echo $createdShipment->getStatus()."\n"; // should be 'open'
echo $createdShipment->getShipment()."\n"; // the number for the newly created shipment
```

### Add packages to shipments

[](#add-packages-to-shipments)

```
$addedShipmentPackages = $asendia->addPackagesToShipment(
    $shipmentNumber,
    $manifest,
    AsendiaWebApiClient::LABEL_TYPE_PDF
);

echo $addedShipmentPackages->getShipment()."\n"; // the number for the shipment
foreach ($addedShipmentPackages->getPackages() as $package) {
    echo $package->getPckId()."\n"; // the PckId
    echo $package->getLabelFile()."\n"; // get the filename for the label
}
```

### Close a shipment

[](#close-a-shipment)

```
$closedShipment = $asendia->closeShipment($shipmentNumber);

echo $closedShipment->getShipment()."\n"; // the number of the shipment
echo $closedShipment->getStatus()."\n"; // should be 'closed'
```

### Retrieve a PDF label

[](#retrieve-a-pdf-label)

```
$pdfLabel = $asendia->retrieveLabelAsPdf($filename);

echo $pdfLabel->getLabelFile()."\n"; // the filename of the label
echo $pdfLabel->getEncodedContent()."\n"; // the base64 encoded content
echo $pdfLabel->getContent()."\n"; // the base64 decoded content (binary/raw)
$pdfLabel->writeContentToFile('/path/to/whatever.pdf'); // writes content to file
```

### Retrieve a JPEG label

[](#retrieve-a-jpeg-label)

```
$jpegLabel = $asendia->retrieveLabelAsJpeg($filename);

echo $jpegLabel->getLabelFile()."\n"; // the filename of the label
echo $jpegLabel->getEncodedContent()."\n"; // the base64 encoded content
echo $jpegLabel->getContent()."\n"; // the base64 decoded content (binary/raw)
$jpegLabel->writeContentToFile('/path/to/whatever.jpg'); // writes content to file
```

### Retrieve a PNG label

[](#retrieve-a-png-label)

```
$pngLabel = $asendia->retrieveLabelAsPng($filename);

echo $pngLabel->getLabelFile()."\n"; // the filename of the label
echo $pngLabel->getEncodedContent()."\n"; // the base64 encoded content
echo $pngLabel->getContent()."\n"; // the base64 decoded content (binary/raw)
$pngLabel->writeContentToFile('/path/to/whatever.png'); // writes content to file
```

License
-------

[](#license)

MIT, see LICENSE.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

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

### Community

Maintainers

![](https://www.gravatar.com/avatar/0d6029bd16a0e8a9b97358a75b54affa6baadc1d9b0ca7eab2b6dd6c681ad7a8?d=identicon)[simensen](/maintainers/simensen)

---

Top Contributors

[![simensen](https://avatars.githubusercontent.com/u/191200?v=4)](https://github.com/simensen "simensen (32 commits)")

### Embed Badge

![Health badge](/badges/cpapdotcom-asendia/health.svg)

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

###  Alternatives

[friendsofsymfony/rest-bundle

This Bundle provides various tools to rapidly develop RESTful API's with Symfony

2.8k73.3M319](/packages/friendsofsymfony-rest-bundle)[php-http/discovery

Finds and installs PSR-7, PSR-17, PSR-18 and HTTPlug implementations

1.3k309.5M1.2k](/packages/php-http-discovery)[pusher/pusher-php-server

Library for interacting with the Pusher REST API

1.5k94.8M293](/packages/pusher-pusher-php-server)[react/http

Event-driven, streaming HTTP client and server implementation for ReactPHP

78026.4M414](/packages/react-http)[php-http/curl-client

PSR-18 and HTTPlug Async client with cURL

48347.0M384](/packages/php-http-curl-client)[smi2/phpclickhouse

PHP ClickHouse Client

84310.1M71](/packages/smi2-phpclickhouse)

PHPackages © 2026

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