mimicak/shipway-php-sdk

PHP client for Shipway API

Maintainers

Package info

github.com/MimicAk/shipway-php-sdk

pkg:composer/mimicak/shipway-php-sdk

Statistics

Installs: 9

Dependents: 0

Suggesters: 0

Stars: 2

Open Issues: 0

v1.0.1 2026-02-04 06:11 UTC

This package is auto-updated.

Last update: 2026-03-04 14:48:19 UTC


README

A clean, structured PHP SDK for interacting with the Shipway API, providing support for order management, courier services, rate calculation, tracking, and manifests.

This SDK is designed as a Composer package, following PSR-4 autoloading and a clear separation of concerns (Config โ†’ Client โ†’ Resources โ†’ Models).

๐Ÿ“ฆ Installation

Install via Composer:

composer require mimicak/shipway-php-sdk

Or include it manually by adding it to your composer.json.

๐Ÿ”ง Requirements

  • PHP >= 7.4
  • Composer
  • cURL enabled

๐Ÿง  Architecture Overview

The SDK is structured into logical layers:

src/
โ”œโ”€โ”€ Client          # HTTP & response handling
โ”œโ”€โ”€ Config          # API configuration & endpoints
โ”œโ”€โ”€ Exceptions      # Domain-specific exceptions
โ”œโ”€โ”€ Models
โ”‚   โ”œโ”€โ”€ Request     # Request DTOs
โ”‚   โ”œโ”€โ”€ Response    # Response DTOs
โ”‚   โ””โ”€โ”€ Core models (Order, Address, Product, etc.)
โ”œโ”€โ”€ Resources       # API feature modules
โ””โ”€โ”€ Shipway.php     # SDK entry point

๐Ÿš€ Quick Start

1๏ธโƒฃ Create Configuration

use Shipway\Config\Configuration;

$config = new Configuration([
    'api_key' => 'YOUR_API_KEY',
    'base_url' => 'https://app.shipway.com/api'
]);

2๏ธโƒฃ Initialize SDK

use Shipway\Shipway;

$shipway = new Shipway($config);

The Shipway class is the main entry point. All API interactions go through resource accessors.

๐Ÿ“ฆ Resources & Usage

๐Ÿงพ Orders

$orders = $shipway->orders();

Supported operations:

  • Create order
  • Fetch order details
  • Fetch order list
  • Cancel shipment
  • Generate manifest

Example:

use Shipway\Models\Request\ShipmentBooking\GetOrdersRequest;

$request = new GetOrdersRequest([
    'from_date' => '2025-01-01',
    'to_date'   => '2025-01-31'
]);

$response = $shipway->orders()->getOrders($request);

๐Ÿšš Courier Services

$courier = $shipway->courier();

Supported operations:

  • Get courier list
  • Rate calculation
  • Pincode serviceability
  • Shipment tracking

Example โ€“ Rate Calculation:

use Shipway\Models\Request\Carriers\GetCarrierRates;

$request = new GetCarrierRates([
    'pickup_pincode'   => '560001',
    'delivery_pincode' => '110001',
    'weight'           => 1.5,
    'cod'              => true
]);

$response = $shipway->courier()->getRates($request);

๐Ÿญ Warehouse

$warehouse = $shipway->warehouse();

Handles warehouse-related Shipway APIs such as listing or configuration (based on API availability).

๐Ÿ“š Models

Core Models

  • Order
  • OrderListItem
  • Address
  • Product
  • ShipmentStatusScan

Request Models

Located in:

src/Models/Request/

These classes encapsulate API request payloads and prevent passing raw arrays.

Response Models

Located in:

src/Models/Response/

These map API responses into typed PHP objects.

โš ๏ธ Exception Handling

All exceptions extend Shipway\Exceptions\ShipwayException.

Possible exceptions include:

  • AuthenticationException
  • ValidationException
  • RateLimitException
  • NetworkException
  • ConfigurationException
  • ApiException
  • WebhookException

Example:

try {
    $shipway->orders()->getOrders($request);
} catch (\Shipway\Exceptions\ShipwayException $e) {
    echo $e->getMessage();
}

๐Ÿ” Configuration Errors

If the SDK is misconfigured (missing API key, invalid base URL), a ConfigurationException is thrown during initialization or request execution.

๐Ÿงช Examples

The examples/ directory is reserved for future usage samples and integration demos.

๐Ÿงฉ Extensibility

  • All API modules extend AbstractResource
  • HTTP logic is centralized in HttpClient
  • Response parsing is handled by ResponseHandler
  • Exception mapping is centralized in ExceptionFactory

This makes the SDK easy to extend without breaking existing functionality.

๐Ÿ“„ License

MIT License.

๐Ÿค Contributing

Pull requests are welcome. Please ensure:

  • PSR-12 compliance
  • Typed models for requests/responses
  • No breaking changes without version bumps

๐Ÿ“ฌ Support

For issues, feature requests, or API changes, open an issue on the repository.