承接 sonnenglas/shiplogic-php-sdk 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

sonnenglas/shiplogic-php-sdk

Composer 安装命令:

composer require sonnenglas/shiplogic-php-sdk

包简介

Unofficial PHP SDK for the Shiplogic REST API — the shipping platform behind The Courier Guy and other South African carrier brands. Covers rate quotes, shipments, label PDFs, cancellation, tracking and webhook payloads.

README 文档

README

Unofficial PHP SDK for the Shiplogic shipping platform — the API behind The Courier Guy and other South African carrier brands.

Covers rate quotes, shipment CRUD, label and sticker PDF downloads, cancellation, tracking events, and inbound webhook payloads (tracking-event, shipment-note, parcel-dimension-changes, shipment-address-changes). Hand-crafted, dependency-light (Guzzle only), with first-class value objects and response DTOs.

Requirements

  • PHP 8.1+
  • ext-json
  • guzzlehttp/guzzle ^7.1

Installation

composer require sonnenglas/shiplogic-php-sdk

Usage

use Sonnenglas\Shiplogic\Shiplogic;
use Sonnenglas\Shiplogic\ValueObjects\Address;
use Sonnenglas\Shiplogic\ValueObjects\Contact;
use Sonnenglas\Shiplogic\ValueObjects\Parcel;
use Sonnenglas\Shiplogic\ValueObjects\ShipmentRequest;
use Sonnenglas\Shiplogic\Enums\ServiceLevel;
use Sonnenglas\Shiplogic\Enums\AddressType;

// Shiplogic uses a single API host (api.shiplogic.com); sandbox vs production
// is decided by the API token, not the URL. `productionMode` is kept for
// backwards compatibility but no longer changes the base URI.
$shiplogic = new Shiplogic(apiToken: '...');
$shipmentService = $shiplogic->getShipmentService();

$sender = new Address(
    streetAddress: '16 Viljoen Street',
    localArea: 'Lorentzville',
    city: 'Johannesburg',
    zone: 'GP',
    country: 'ZA',
    code: '2094',
    company: 'Sonnenglas',
    type: AddressType::Business,
);

$recipient = new Address(
    streetAddress: '10 Midas Avenue',
    localArea: 'Olympus AH',
    city: 'Pretoria',
    zone: 'GP',
    country: 'ZA',
    code: '0081',
    type: AddressType::Residential,
);

$parcel = new Parcel(lengthCm: 30.0, widthCm: 20.0, heightCm: 10.0, weightKg: 2.0);

$request = new ShipmentRequest(
    collectionAddress: $sender,
    collectionContact: new Contact(name: 'Warehouse Op', mobileNumber: '+27110000000', email: 'ops@example.com'),
    deliveryAddress: $recipient,
    deliveryContact: new Contact(name: 'Jane Doe', mobileNumber: '+27821234567', email: 'jane@example.com'),
    parcels: [$parcel],
    serviceLevelCode: ServiceLevel::Economy,
    customerReference: 'ORDER-123',
);

$response = $shipmentService->createShipment($request);

echo $response->shortTrackingReference;        // e.g. "3BM3"
echo $response->customTrackingReference;       // e.g. "SLX3BM3"

$label = $shipmentService->getLabel($response->id);
echo $label->url;                              // signed S3 URL, valid 24h

Services

The Shiplogic facade exposes three services:

  • getShipmentService() — create / fetch / cancel shipments, download label PDFs and sticker labels.
  • getRatesService() — fetch rate quotes for a collection/delivery pair.
  • getTrackingService() — fetch a shipment's status and event timeline.

Webhooks

Shiplogic delivers webhooks for tracking-event, shipment-note, parcel-dimension-changes, and shipment-address-changes topics. The SDK ships first-class payload DTOs under Sonnenglas\Shiplogic\Webhooks\* so consumers can hydrate inbound payloads without re-parsing JSON.

use Sonnenglas\Shiplogic\Webhooks\TrackingEventPayload;

$payload = TrackingEventPayload::fromArray(json_decode($request->getBody(), true));

Testing

composer install
./vendor/bin/phpunit --testsuite Unit

Integration tests are gated on a sandbox token in tests/.env:

SHIPLOGIC_SANDBOX_TOKEN=your-sandbox-token ./vendor/bin/phpunit --testsuite Integration

License

MIT. See LICENSE.

统计信息

  • 总下载量: 60
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-05-19

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固